I have an animation as a batch of .png files (100 files). The background is transparent in the source .png files. I want to convert them into a single animated gif. I have tried this command:
convert -delay 0 -loop 0 -alpha set *.png ani.gif
But the result is the following (green is the HTML page background):
How should I remove the previous frames from an every following one?
I've found -dispose previous.
UPDATE
OK, convert -delay 0 -loop 0 -alpha set -dispose previous *.png ani.gif
The solution is here:
http://www.alecjacobson.com/weblog/?p=2601
The magic keyword seems to be “dispose” and calling the following fixed the problem:
convert -dispose 2 screencapture-*.tga screencapture.gif
Related
I am trying to make a gif with images using convert. But in the resulting gif, the images are just stacking one over the other.
Here is the created gif : https://i.imgur.com/EgISW2y.gif
I tried creating it with simple command :
$ convert -delay 8 -loop 0 plot_* result.gif
Try using the -dispose setting with previous option, which disposes the previous frames after they are displayed:
convert -dispose previous -delay 8 plot_* -loop 0 result.gif
Further reading here.
I am trying to stitch together a bunch of .png's which contain some alpha (transparency) but which have a uniformly white background. The png's look fine individually, but in the resulting .gif some frames acquire a patchy background that appears to have the same RGBA color as some of the points being animated.
I have tried the following commands
convert -delay 1 im*.png anim.gif
convert -delay 1 -alpha set im*.png anim.gif
convert -delay 1 -alpha set -dispose background im*.png anim.gif
convert -delay 1 -alpha set -dispose previous im*.png anim.gif
convert -delay 1 -alpha set -dispose previous -background white im*.png anim.gif
pretty much just trying additional flags to see if anything happens to fix the glitch, but I get the same behavior in every case. Anyone have a fix?
Ah, this question led me to the right answer --
convert -delay 1 -layers Optimize im*.png anim.gif
works!
I'm using ImageMagick to rotate animated gifs. Simply:
convert image.gif -rotate 32 -alpha set -background none output.gif
Output:
https://s3-eu-west-1.amazonaws.com/uploads-eu.hipchat.com/108112/892631/ATp8mXXrDdSkCNu/sowa-test2.gif
Does anyone have a clue why output image is distorted this way and how to avoid this?
Without seeing the original image, I would suggest extracting each image, apply rotation, and then re-build the animated gif.
Example using the following gif:
convert anim_none.gif -scene 1 +adjoin tmp_%02d.gif
mogrify -rotate 32 -alpha set -background none tmp_*.gif
convert tmp_*.gif -loop 0 final.gif
And note: quality is expected to degrade with rotation operations.
The solution from emcconville didn't quite work for me. Part of the issue may have been that my layers were transparent and so not all the same dimensions. However, using his solution as a base and then modifying it based on things I saw elsewhere, I was able to get my gif rotated:
convert my_gif.gif -background transparent \
-virtual-pixel background -coalesce tmp_%02d.gif
mogrify -rotate -45 -background transparent -virtual-pixel background tmp_*.gif
convert tmp_*.gif -loop 0 my_gif_rotated.gif
Hopefully this helps others.
I have a bunch of files labelled 1.png and so on. I'm using the following command line to produce a gif animation:
convert -delay 20 *.png animation.gif
But the frames get superposed sequentially. I did not expect this behavior, what might be wrong?
Thanks
Option -dispose previous:
convert -dispose previous -delay 20 *.png animation.gif
I want to make an animated gif from those .png image:
I do it with this command:
convert -layers OptimizePlus -delay 25x100 ps1-*.png -loop 0 ps1.gif
It made an animated gif successfully, however, the output has very low quality and smaller than input images:
After some search, I got -quality
convert -layers OptimizePlus -delay 25x100 -quality 99 ps1-*.png -loop 0 ps1.gif
But it seems like imagemagick just ignore the parameter.
The problem is that your source PNGs have an alpha channel which is not supported by GIFs. So you have to remove transparency from your source images first. Since you're dealing with multiple source images, you can't use the -flatten method. With newer ImageMagick versions the following should work:
convert -background white -alpha remove -layers OptimizePlus -delay 25x100 ps1-*.png -loop 0 ps1.gif
If your version of ImageMagick is older than 6.7.5, you can try:
convert -bordercolor white -border 0 -layers OptimizePlus -delay 25x100 ps1-*.png -loop 0 ps1.gif
I got the following result with the latter command: