Search code examples
image-processingimagemagickanimated-gifimagemagick-convert

Resizing animated GIF in image creates artifacts


I'm trying to add a blank area around some animated GIFs using imagemagick, but in many cases the resulting larger animations have artifacts. For example, if I start with this image

original image

And run the following command (which has the dispose and coalesce flags which I've thrown in after seeing them online in the hopes they'll help)

convert input.gif -gravity center -dispose previous -extent 500x500 -coalesce output.gif

The result is the following

output image with artifacts

Is there a different command I can run that wouldn't gave the green splotches invade the original image?


Solution

  • You have your syntax wrong for ImageMagick and also need to use -dispose none. You are adding a new color to your animation which likely already used 256 colors.

    Input:

    enter image description here

    convert -dispose none input.gif -coalesce -gravity center -background green -extent 500x500 -layers optimize output.gif
    

    enter image description here

    Change the background color as desired, which you left out of your command.