Jump to content

Help with image quality...


CSmith1128

Recommended Posts

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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.