31

I want to make an animated gif from those .png image:

enter image description hereenter image description hereenter image description hereenter image description here

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:

enter image description here

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.

1 Answer 1

46

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:

animation

3
  • 1
    GIF does support transparency. The result GIF posted in the question is transparent.
    – Hai Zhang
    Nov 3, 2018 at 22:18
  • @DreaminginCode But GIF only supports fully transparent pixels and no alpha channel. That's why you get the jagged edges.
    – nwellnhof
    Nov 4, 2018 at 12:09
  • But there are still plenty of transparent GIFs and a common way people achieve it is to actually only place the semi-transparent pixels on a white background, so that in most cases the edge does not seem to be aliased. There is a border matte option in Photoshop when exporting GIFs, but I haven't find a good way for imagemagick yet.
    – Hai Zhang
    Nov 4, 2018 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.