ImageMagick convert gif with transparency problem

I wrote a script to add watermarks to images on my site. Everything works fine for png / jpg, but gifs should be handled in a more complex 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 the gifs, it works great. But there are a few examples that lead to errors. To worry about this image: image

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

enter image description here

This is not a normal cat. Any suggestions?

+7
source share
1 answer

The problem is that your -splice is applied relative to the layout of the gif frames, and not the full layout of the image. First do -coalesce (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 Animation Modifications from ImageMagick Examples for more information.

+2
source

All Articles