Sunday, February 8, 2009

Creating Transparent .GIFs from .PNG's

Easy one-liner using "convert" from the Imagemagick graphics suite to get decent .gif conversions of most* transparent .png's.

convert [imagename].png -channel Alpha -threshold 80% [imagename].gif

This converts the Alpha channel (the one IE6 has the most problem with) to either completely transparent or opaque based on the 80% threshold.

I say most, because it doesn't work for things like backgrounds or overlays (which are often too dark -- greys are often black, for example.) -- you can change 80% to 60% if you have backgrounds of mostly one colour, but it's not foolproof and often leaves darker marks around the exterior of the image.

No comments: