ImageMagick 转换 gif 时出现透明度问题
我编写了一个脚本来为我网站上的图像添加水印。对于 png/jpg 来说一切正常,但是 gif 图像必须以更复杂的方式处理。我的脚本:
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
对于 95% 的 gif 来说,效果很好。但有一些例子会带来错误。 关注这张图片:
普通猫。仅第一帧包含背景(在 gimp 中查看的图层)。
这不是普通的猫。有什么建议吗?
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:
Normal cat. Only first frame contains background (viewed layers in gimp).
This is not normal cat. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是您的
-splice
是相对于 gif 帧的布局而不是完整图像的布局应用的。首先执行-coalesce
(顺序很重要):请参阅“Simple Modifications of动画”来自 ImageMagick 用法示例更多信息。
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):See "Simple Modifications of Animations" from the Examples of ImageMagick Usage for more information.
以下切换顺序对我有用:
The following switch sequence worked for me: