开发者

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 bring开发者_StackOverflow社区s errors. Concern this image:

ImageMagick convert gif with transparency problem

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

ImageMagick convert gif with transparency problem

This is not normal cat. Any suggestions?


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.


The following switch sequence worked for me:

magick convert input.gif -coalesce -gravity south -background white -splice x100 -gravity southeast -geometry +5+5 -background white null: watermark-text.png -layers composite -bordercolor black -border 1 output.gif

ImageMagick convert gif with transparency problem

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜