I have been creating animated GIF files using GIMP from several frames in PNG format that I created using Jmol and now I would like to know how to make the background of the resulting GIF files transparent. Any pieces of software or websites you suggest should be available for free, please.
Have you done some efforts? See here and there.– Paolo GibelliniOct 11, 2014 at 20:15
I have done that before but that is unsuitable seeing how this GIF is animated, not static as those methods are only helpful for static images. In order to do what you're suggesting by showing me these two questions I'd have to make each of the PNG files I convert into the GIF transparent individually and seeing how I use 60 frames per GIF that would take sometime, especially seeing how in my experience each image takes at least 5 minutes to do, as color alpha is less than perfect and requires some fiddling in order to work.– Josh PintoOct 11, 2014 at 20:34
1I don't know Jmol, but here is a topic related to alpha background (see also here). Have you exported as PNGT the frames?– Paolo GibelliniOct 11, 2014 at 23:22
GIMP can already create GIFs with transparency.– Billy KerrJul 8, 2017 at 10:10
You can do this with GIFsicle, using the following options:
gifsicle -U --disposal=previous --transparent="#ffffff" -O2 anim.gif > anim_trans.gif
anim_trans.gif are the source and destination file names, and
#ffffff is the hex code of the color you want to make transparent (here, pure white).
(The important options here are
--disposal=previous, which together convert the animation into "flipbook mode", where each frame is fully erased before drawing the next one. This allows extra transparency to be added to the frames without letting the earlier frames show through the transparent parts. The
-O2 option is not strictly necessary, but it's likely to shrink the file size of the resulting animation by optimizing the frames to avoid needlessly re-drawing static parts of the animation.)
For a demostration, here's an animation of the human glyoxalase I (GLO1) enzyme from Wikimedia Commons (left), and the same animation with transparency added using the method shown above (right):
Original animation by Wikimedia Commons user WillowW, used under the CC-By 3.0 license.
One detail worth noting is that, if the GIFsicle command doesn't seem to have any effect, you should check that the background color is really correct. For example, for the animation shown above, the actual background color turned out to be
#fdfffc (i.e. very slightly yellow-greenish white) rather than
#ffffff (pure white). You can't actually tell the difference by eye (or, at least, I can't do that on this screen), but it's enough to make GIFsicle consider the two colors different.
Also note that GIF files only support 1-bit transparency, which means that the edges of the transparent regions will not be anti-aliased. This is OK as long as the background you're showing the animation on isn't too far from the original background color, but if it is, you may find that there will be some ugly color fringing around the edges of the animation. Unfortunately, there's not a lot you can do about that, except to choose a more suitable background or to re-render the animation.
Do you have a Windows 7-friendly software alternative to gifsicle I could use instead? I have tried installing the Win32 and 64 binary (I'm using 64 bit Windows 7, from the link on gifsicle's official website) and neither have worked. It just popped up a command prompt, for a sec and then this prompt closed. I have since opened up command prompt (as I understand gifsicle is a command-line based editor) and copy-pasted your commands in (with the actual file names, ofc) and it gave a null file with a warning saying that gifsicle was unrecognized on my system. Dec 12, 2014 at 5:22
Hmm... have you tried using the command prompt and specifying the full path to the gifsicle.exe? Or
cd-ing to the folder you installed gifsicle into, and running the command from there? Or adding that folder into your
%PATH%? Dec 12, 2014 at 11:56
cd-ing to the directory, running that command worked perfectly without a hitch, hence I shall accept your answer. Dec 12, 2014 at 12:51
It is very easy.
Choose: 1) edit
4) select the area which you want to apply.
Similarly to GIFsicle and GIFmagic, EzGIF is an online set of GIF tools that (among other things) let's you do that:
- Choose "Effects"
- upload the GIF
- then use "Replace color with transparency" box
- and apply
(You can then also optimize the result if you want)
If you have imagemagick you can run the command
convert input.gif -transparent white output.gif in a terminal.
Can you explain what that command does? We're looking for longer answers with an explanation, not one-liners. Besides, it looks like it converts the color white to transparent, so will it also select everything that is white in the image?– LucianoAug 9, 2017 at 12:12
You can do this directly from photoshop.
Use the 'Save to Web' option and save as a GIF with transparency. Find the color you want to be transparent from the Color Table. Click it and then click the button I've circled in red.
This will make whichever color you had selected transparent. Save.