Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

png to gif with transparency

I have a png image with some transparency. I would like to transform it to a gif image. I have tried imagemagik using convert myimage.png myimage.gif but transparency is not respected.

Any solution using linux commands? thanks

like image 946
anraT Avatar asked Mar 20 '13 16:03

anraT


1 Answers

What you are doing should work out of box.

However, there's an important limitation of GIF as a format (not related to imagemagick). It does not support semi-transparency (alpha channel). Transparency in GIF is on/off (boolean).

Docs claim that the default behavior is to make pixels with (alpha<50%) fully transparent.

Depending on your image, you may achieve satisfactory results though. For example, by tweaking the threshold (code from ImageMagick docs):

 convert a.png -channel A -threshold 15%   a_no_shadow.gif

See more info on available options at: http://www.imagemagick.org/Usage/formats/#gif

like image 95
sbat Avatar answered Jan 01 '23 13:01

sbat