CSmith1128 Posted August 25, 2010 Share Posted August 25, 2010 Hello. I was wondering if there is any way to remove the white pixels from around a transparent png image? When I use imageimagecopymerge to place a transparent PNG on top of another image with a dark background, the top image has a few white pixels around the border. Is there any way to remove these white pixels? I attached an example of the image with the white pixels. Thanks [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
nethnet Posted August 25, 2010 Share Posted August 25, 2010 You can make certain colors be considered transparent with GD Library, but I think the best bet for you would be to just actually open the images up in PhotoShop and erase the white pixels surrounding your image. Put the image on a layer on top of a dark background in PhotoShop and you will see that the outline is part of the image file, not a malfunction with GD Library. Doing this with GD would be very cumbersome, as I highly doubt that each of those pixels surrounding the image are the EXACT same color. They are most likely varying shades of light gray and white. Quote Link to comment Share on other sites More sharing options...
CSmith1128 Posted August 25, 2010 Author Share Posted August 25, 2010 Thanks for the reply.. I actually tried that before I posted my question and the white dots weren't there. You said I could make certain colors transparent in the image.. Which function would I use to set those colors? Thanks Quote Link to comment Share on other sites More sharing options...
nethnet Posted August 25, 2010 Share Posted August 25, 2010 Look into this function: imagecolortransparent() But like I said, you might have to define several colors as transparent in order to get that to work, since there might be varying shades of "white" around the image. You might also have to look into alpha channels to get this to work properly: imagesavealpha() Also note that this won't let you simply "erase" the line around the given image. It will simply make ALL occurances of supplied color in the image transparent. So, if you choose to make white (#FFFFFF) transparent, you won't be able to use this method if your image contains white anywhere that you might need it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.