使用ImageMagick将动画gif的背景更改为透明,但框架重叠。怎么解决? [英] Using ImageMagick to change background of an animated gif into transparent, but frames overlapped. How to solve?
问题描述
我想将gif背景更改为透明,我使用ImageMagick的以下命令:
I want to change the gif background into transparent, and I use the following command of ImageMagick:
convert input.gif -transparent white output.gif
convert input.gif -transparent white output.gif
但是,输出有鬼影效果,后面的帧与之前的帧重叠。
However, the output has ghosting effect, the later frames overlapped with its previous frames.
//对不起,我发布自己的图片并没有良好的声誉。
这里有一个例子: http://tieba.baidu.com/p/1090763568
//Sorry, I don't have enouth reputation to post my own images. A example is here: http://tieba.baidu.com/p/1090763568
如何让它们不重叠?或者换句话说,没有鬼影效果?
How can I make them do not overlap? Or in other words, no ghosting effect?
推荐答案
我认为回答就是它是一个制作精良的动画,适合您的目的。您可以通过ImageMagick看到动画包含12个这样的帧:
I think the "answer" is that it is a badly made animation for your purposes. You can see that the animation consists of 12 frames like this with ImageMagick:
identify anim.gif
anim.gif[0] GIF 400x350 400x350+0+0 8-bit sRGB 256c 106KB 0.000u 0:00.000
anim.gif[1] GIF 1x1 400x350+0+0 8-bit sRGB 256c 106KB 0.000u 0:00.000
anim.gif[2] GIF 226x152 400x350+85+8 8-bit sRGB 256c 106KB 0.000u 0:00.000
anim.gif[3] GIF 218x152 400x350+89+8 8-bit sRGB 256c 106KB 0.000u 0:00.000
anim.gif[4] GIF 210x152 400x350+93+8 8-bit sRGB 256c 106KB 0.000u 0:00.000
anim.gif[5] GIF 202x152 400x350+97+8 8-bit sRGB 256c 106KB 0.000u 0:00.000
anim.gif[6] GIF 194x152 400x350+101+8 8-bit sRGB 256c 106KB 0.000u 0:00.000
anim.gif[7] GIF 194x152 400x350+101+8 8-bit sRGB 256c 106KB 0.000u 0:00.000
anim.gif[8] GIF 202x152 400x350+97+8 8-bit sRGB 256c 106KB 0.000u 0:00.000
anim.gif[9] GIF 210x152 400x350+93+8 8-bit sRGB 256c 106KB 0.000u 0:00.000
anim.gif[10] GIF 218x152 400x350+89+8 8-bit sRGB 256c 106KB 0.000u 0:00.000
anim.gif[11] GIF 226x152 400x350+85+8 8-bit sRGB 256c 106KB 0.000u 0:00.000
您可以将图像分割成其构成框架,并使白色区域透明,如下所示:
You can split the image into its constituent frames and make the white areas transparent like this:
convert anim.gif -transparent none frame-%02d.gif
-rw-r--r-- 1 mark staff 9777 4 May 11:11 frame-11.gif
-rw-r--r-- 1 mark staff 9732 4 May 11:11 frame-10.gif
-rw-r--r-- 1 mark staff 9681 4 May 11:11 frame-09.gif
-rw-r--r-- 1 mark staff 9835 4 May 11:11 frame-08.gif
-rw-r--r-- 1 mark staff 9533 4 May 11:11 frame-07.gif
-rw-r--r-- 1 mark staff 9479 4 May 11:11 frame-06.gif
-rw-r--r-- 1 mark staff 9986 4 May 11:11 frame-05.gif
-rw-r--r-- 1 mark staff 9907 4 May 11:11 frame-04.gif
-rw-r--r-- 1 mark staff 10070 4 May 11:11 frame-03.gif
-rw-r--r--@ 1 mark staff 10099 4 May 11:11 frame-02.gif
-rw-r--r-- 1 mark staff 43 4 May 11:11 frame-01.gif
-rw-r--r--@ 1 mark staff 15917 4 May 11:11 frame-00.gif
您还可以像这样一起剪辑所有帧:
You can also montage all the frames together like this:
convert anim.gif -transparent white miff:- | montage -tile 3x -frame 5 - montage.jpg
如果您尝试将框架重新放在一起,并使用<处理方法背景
,您将丢失仅出现在第一帧中的 welcome
这个词:
If you try to put the frames back together with a disposal method of background
, you will lose the word welcome
which only appears in the first frame:
convert -dispose background frame-0* a.gif
如果您在动画制作动画之前尝试将第一帧(因此您有欢迎)与其他帧合成,您将获得一个黑色幽灵,因为男孩和女孩角色也出现在第一帧中:
If you try and composite the first frame (so you have "welcome") with each of the others before animating them, you will get a black ghost because the boy and girl characters also appear in the first frame:
convert frame-00.gif frame-02.gif -geometry +85+8 -composite x.gif
onl我看到的解决方案是将第一帧带入Photoshop并移除男孩和女孩,然后重建动画......但是再一次,我不是动画专家,现在所有的帧都是在桌子上,其他人可能会告诉你一个更简单的方法。
The only solution I see is to take the first frame into Photoshop and remove the boy and girl, then rebuild the animation... but then again, I am no expert in animation and now that all the frames are "on the table", someone else may be able to tell you an easier method.
这篇关于使用ImageMagick将动画gif的背景更改为透明,但框架重叠。怎么解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!