Let’s Make An Animated GIF (With ImageMagick)

Today’s article is just for fun, where we learn how to make an animated gif in the terminal – with ImageMagick. It’s just for fun and not something you’ll likely need unless you’re some sort of content creator. (We don’t know any of those, do we?) Anyhow, let’s go ahead and make an animated .gif in the terminal.

Today, we’ll be using ‘ImageMagick’. As far as I know, imagemagick has one of the longest and most complicated man pages. It’s huge and a capable tool in the right hands. ImageMagick has all sorts of capabilities but a new user isn’t likely to use them because of the complexity involved.

And, ImageMagick is complex… In fact, it defines itself as:

ImageMagick – is a free software suite for the creation, modification and display of bitmap images.

That’s an accurate description, I think… Except, well, it does a whole lot more than that. We’ll be using the .gif format, while the man page description only mentions bitmap. So, there’s a lot to the application.

Thus, without further ado, we make an animated gif in the terminal…

How To Make An Animated GIF:

The ImageMagick application is terminal-based. So, you’re going to need an open terminal. If you want, you can just press CTRL + ALT + T and your default terminal should open.

If you don’t have ImageMagick installed, you’ll need to install it. If you’re using a mainstream distro, it’s possibly installed already. Otherwise, it’ll certainly be in your default repositories as it’s a pretty major tool. For example, an apt user would just use a command like this (adjust for your package manager):

With your terminal now open and imagemagick properly installed, let’s just see how long that man page is:

See? I wasn’t kidding!

Now, here’s what you need to make an animated gif:

  1. A dedicated folder, perhaps in your ~/Pictures directory.
  2. A few images of the same format, we’ll use .jpg in our example.
  3. A terminal opened in the above-mentioned dedicated folder.

The first thing to learn is that this command is going to take those images and turn them into an animated file with the .gif extension. It is going to organize them alphanumerically. So, you should rename the  .jpg files in the order you wish to see them (assuming the order matters to you).

All set? Have you done all those things? Are you 100% prepared? Good!

The command we’re looking for would be:

Alright, so the ‘delay 100’ is how long each image will be shown – in hundredths of a second. The ‘-loop 0’ tells it to loop infinitely, or you can pick your own number of times. The ‘*.jpg’ means use all the .jpg files in that directory. The ‘file_name’ is the name of the file you want to have as your output.

See? Pretty simple. An example command might be something like:

Let the command run, and it is a pretty speedy process unless you have a whole lot of images, and you’ll get an animated gif as a result. As these tend to have smaller file sizes, it’s sometimes a better option than sharing a larger video file. It depends on your circumstances, I suppose.

NOTE: This article has been edited to correct the time delay, the delay between changing images. Thanks @wizardfromoz!

Closure:

There you have it. You have an article that tells you how to make an animated gif with ImageMagick. The ImageMagick application has a ton of options, making it daunting for a new Linux user. So, this is just a tiny bite. This is just one of many ways to use ImageMagick. Instead of learning the whole application at once, you can do so in chunks – learning only what you need.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.