Converting PNG to gif and maintaining edge quality

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
mrshake
Posts: 35
Joined: 2008-11-18T08:18:51-07:00

Converting PNG to gif and maintaining edge quality

Post by mrshake »

Here is the PNG I am starting with:

Image

Here is the gif I'm getting:

Image

I really need the same soft edges from the PDF in the gif... thoughts?
User avatar
Randolf
Posts: 19
Joined: 2007-10-08T20:58:27-07:00
Location: Beautiful British Columbia, Canada

Re: Converting PNG to gif and maintaining edge quality

Post by Randolf »

You probably need to set a different background colour. GIF is a bit limited this way compared to PNG because only one background colour may be selected for the transparency, while PNG images seem to handle transparency very differently (and in a way that makes it possible to show gradient transparencies on a multi-coloured background).

In zooming into your second sample image, it appears that the edges are coloured in a way to blend into a dark (black?) background. If you can stay with the PNG format in your PDFs, then you won't have to worry about matching the background colours for GIF transparency (I hope I didn't misunderstand your question).
Randolf Richardson - randolf@richardson.tw
Greater Vancouver Area, Beautiful British Columbia, Canada

"Petition to make all spam illegal in Canada:"
http://www.lumbercartel.ca/law/canada/s-220/
mrshake
Posts: 35
Joined: 2008-11-18T08:18:51-07:00

Re: Converting PNG to gif and maintaining edge quality

Post by mrshake »

I didn't mean PDF.. I keep doing that.. haha...

The original image is a full sized un-rotated version of the final image... when I rotate.. I rotate on a transparent background.... I'll play with background tools a bit.
User avatar
Randolf
Posts: 19
Joined: 2007-10-08T20:58:27-07:00
Location: Beautiful British Columbia, Canada

Re: Converting PNG to gif and maintaining edge quality

Post by Randolf »

With GIF, you need to specify the "matte" which is the default background colour to use for matching the gradient transparent portions of the image. I'm not sure if ImageMagick uses the same name for this ("matte" is the terminology used in Adobe's Photoshop).

With PNG, the "matte" isn't needed because it's more advanced in that regard.

Recently I changed the background on a web site for one of my clients from a flat colour to multi-coloured (e.g., it shaded from dark to light to create a "richer" appearance), and the logos and vehicles that sat in front of this background were a combination of GIF and JPeG images which had some gradient transparencies around the edges -- on a flat background everything looked just fine, but on this new multi-coloured background the edges appeared to have bits and pieces of the previous "flat" background colour just outside the edges. Taking the original Photoshop images and saving them as PNG resolved that problem and everything looks correct now; if I had wanted to stay with GIF and JPeG, then I would have either had to include the multi-coloured background which wouldn't be ideal (especially if the image was moved to a different location {by the web browser, for a variety of reasons including user customizing font sizes, zooming their images, using non-typical DPI settings in certain Operating Systems, etc.} in front of the actual background), split or not.

So, in short, I highly recommend using PNG instead of GIF when needed. Compression is generally better with GIF though, and it supports animation (for PNG animation you need to use MNG, but I find that it's not widely supported by web browsers), so GIF still has plenty of value. For pictures of people, since GIF is limited to a maximum of 256 colours, PNG will also usually yield better results.

Please do post back here with your anticipated success on getting ImageMagick to do what you need with GIF.
Randolf Richardson - randolf@richardson.tw
Greater Vancouver Area, Beautiful British Columbia, Canada

"Petition to make all spam illegal in Canada:"
http://www.lumbercartel.ca/law/canada/s-220/
mrshake
Posts: 35
Joined: 2008-11-18T08:18:51-07:00

Re: Converting PNG to gif and maintaining edge quality

Post by mrshake »

Thanks for all the ideas!!! I just relised I had been looking at these images through the eyes of firefox and windows, but never through IE. The PNG displayed in IE has a black background.. that could explain why, when converted to gif its showing black jagged edges..... I wonder if that might be a clue into where I need to go!
Post Reply