Converting a PNG to GIF with Transparency Matte

December 4th, 2006 by bbieber Leave a reply »

A couple months ago a coworker and I were trying to figure out how to use ImageMagick to convert a bunch of .png images to .gif. Using mogrify, the process is fairly straightforward, but preserving the transparency by matting alpha pixels against a white background was pretty tricky.

Here’s the issue:

Original png zip icon
Bad gif zip icon
Good gif zip icon

The epic search turned up the following command:

mogrify -format gif -bordercolor white -border 0x0  application-zip.png.png

Which gives you the good gif above.

Advertisement

Leave a Reply