Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick convert gif with transparency problem

I wrote a script to add watermark to images on my site. Everything works ok for png/jpg, but gif images must be treaten by more complicated way. My script:

convert -splice x36 -gravity south -background white image.gif \
-coalesce -gravity SouthEast -geometry +0+0 -background white \
null: watermark-text.png -layers composite new-image.gif

For 95 percent of gif it works fine. But there are some examples, that brings errors. Concern this image: image

Normal cat. Only first frame contains background (viewed layers in gimp).

enter image description here

This is not normal cat. Any suggestions?

like image 644
dfens Avatar asked Aug 02 '11 21:08

dfens


1 Answers

The problem is that your -splice is being applied relative to the gif's frames' layout rather than the complete image's layout. Do the -coalesce first (order matters):

convert -coalesce -splice x36 -gravity south -background white image.gif \
-gravity SouthEast -geometry +0+0 -background white \
null: watermark-text.png -layers composite new-image.gif

See "Simple Modifications of Animations" from the Examples of ImageMagick Usage for more information.

like image 79
blahdiblah Avatar answered Oct 16 '22 06:10

blahdiblah