How To Create Animated GIFs from a PNG Sequence with ImageMagick and the Command Line
This tutorial demonstrates how to create animated GIFs from a PNG sequence using ImageMagick and the command line on Linux. What you are seeing is a seizure inducing animation that we created for our series, Superusers: The Legendary GNU/Linux Show, which I strongly encourage you to watch if you are interested in Linux, free open-source software, and the surreal.
If you haven’t already, install ImageMagick:
sudo apt-getinstall imagemagick
With ImageMagick installed, navigate to the directory containing your image sequence. In my case, my directory is ‘shebang’, on my Desktop.
ImageMagick is very easy to use and easy to understand. We will be using ImageMagick’s convert program. We can see how convert works on its man page:
On the convert man page, you will see a line explaining its use:
We’re going to pass the convert program an input option, an input file and specify any output options and the file name.
At the prompt enter the following command:
Let’s walk through this, step by step. Our first input option is -delay . This sets the length of the pause between ‘frames’ in our animation. Here, we set it to 2. Next we use the -loop switch to determine how often we want the animation to repeat. In our case, we want to it run continuously, so we set this option to 0. If you only want it to run once, set it to 1. Twice, 2, and so on. Our input-file is a sequence, so we use the ‘wild card’, *, to tell the convert program to use all files ending with .png. We’re using the PNG sequence I exported from Blender at 1920 x 1080, which is what we want for video, but way too big for a GIF. Here we set our output-option to scale down with -scale at 480×270. Lastly, we enter the name and file format of our output, which in this case is a .gif, shebang.
Learn With Us
We want to take you on a journey through the other side of the creative process: making a living. Explore the necessary evils of business as we develop a creative media studio using free and open source software. Sign up for our New Moon newsletter delivered on, you guessed it, every New Moon.
Master the commands and structure of the fastest-growing computer operating system, Linux. Join super friends Adelie the penguin and Aramis the gnu on surreal adventures in the file tree. Learn the essential commands you need to take greater control of your computer in Superusers: The Legendary GNU/Linux Show.
How To Create Animated GIFs from a PNG Sequence with ImageMagick and the Command Line was posted by Jared on . Jared is one half of the creative force behind Dototot. In addition to writing scripts and tutorials, he draws and animates both the digital and the analog.