There are some GIMP tutorials about adding a background for a green screen GIF, i.e. chroma keying. But none of them is about a green screen animated GIF (e.g. the "Confused Travolta" meme).

GIMP can open animated GIFs. But can a background be added?

  • I don't use gimp, but my guess is that while one frame isn't that hard to key out, repeating the same process on multiple frames might not be as simple with gimp. Typically you'd use a video editing application to do this. As you might know, this exact video is part of a tutorial for keying out the bg with Sony vegas pro. Other apps you could use: Premiere, After effects, Final cut pro, Hitfilm, Davinci resolve, Windows movie maker, iMovie... etc.
    – Joonas
    Dec 12, 2015 at 0:51

1 Answer 1


An animated gif is a sequence of images (in your example, 100 images), and is technically possible - but obviously not suggested - open the file with the GIMP and edit each layer.

As you said, there are a lot of simple solutions for images with an alpha background (perhaps the simpler way is described here), but replacing a color is a bit difficult. There is an old GIMP plugin, the GIMP Animation Package or GAP, which is designed to work on multiple layers. Here is the answer to a question similar to yours.

Last version of GAP is for GIMP 2.6, but it seems to work even with GIMP 2.8 (read here).

Another way is use ImageMagick:

convert test.gif -fill "#fb8245" -opaque "#1cd000" another_color.gif

another background

I've posted here just a frame, but convert works on all the layers. #1CD000 is the green to be replaced. You can also replace the green background with a transparent one, using "none" as a fill color (and adding an alpha channel):

convert test.gif -alpha set -channel RGBA -fill none -opaque "#1cd000" alpha_bg.gif

alpha background

As you see, in the image there are a lot of boring pixels of other kind of green. ImageMagick comes out with the fuzz modifier (you can adjust it by trying):

convert test.gif -fuzz 15% -alpha set -channel RGBA -fill none -opaque "#1cd000" alpha_bg.gif

a bit of fuzzy threshold

On ImageMagick websiste there are a lot of pages related to generate or modifying animations. Try and enjoy!

For a more professional work in my opinion you need an animation specific package.

  • Thanks for the detailed ideas! It should be noted ImageMagick breaks the animated GIF into different frames, which require a different program to piece them together again. With that said, can ImageMagick also append a certain background image to all those frames?
    – LWC
    Dec 14, 2015 at 1:48
  • ImageMagick performs this operation without breaking the GIF in frames (the process is done only in the memory of the program, try the command in my answer!). Why do you think it should necessary perform a 2-step operation (and with a different program to piece the frames)? It would be absolutely not practical! ImageMagick can split the GIF in frames (if you need it) and it can also add a background (see here) to the animation. I suggest you to read the documentation, try by yourself and update us on your efforts. Dec 14, 2015 at 10:36
  • @LWC Video editing applications are way more equipped to handle video editing. To me it seems foolish to try to find alternative ways, since there are many free video editing applications out there, that give you way more control
    – Joonas
    Dec 14, 2015 at 12:20
  • What do you mean, I wrote it because I ran your command and it has splitted up the files into frames. Anyway, GIF is an image file in the end so it lives in both worlds.
    – LWC
    Dec 14, 2015 at 20:13
  • @LWC Even though gif is a moving image, image editing applications aren't well equipped for keying multiple frames. Also, you can make any video into a gif, but that doesn't mean it makes sense to edit it as a gif or in image editing application. The last point I'm going to make is that the file you have there is .gifv, which is Imgur's flavor of gif, which is actually a container for either .webm or .mp4, which are both video formats. If you want to do it the hard way, I'm not going to try and stop you any longer.
    – Joonas
    Dec 15, 2015 at 0:40

Your Answer

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

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