Best Tools to Make Animated GIF in Linux Systems

October 21, 2016 | By
| 4 Replies More

Animated GIF images have become an art of its own, with funny scenes and memes flooding the internet. Animated GIFs are also useful to us geeks, for example for showing interactive terminal output. When there is not enough content to warrant entire video but you still need moving picture, animated GIF is what you need. So today we will show three ways you can create GIFs using open source Linux software.

Using gtk-recordmydesktop

Lets first install the software we need. We need above mentioned screen casting software,  and we also need imagemagick and mplayer. So lets install them.

sudo apt-get install imagemagick mplayer gtk-recordmydesktop

Next we use recordmyDesktop software to record terminal window while we execute some command. We will keep it simple so we will just ping google. When that is recorded, and file is saved in ~/Videos/mygif.ogv we move to next step. First cd into videos directory.

cd Videos/

mkdir img_mygif

Then we need to dissemble the video to frames

miki@miki-X550JK:~/Videos$ mplayer -ao null mygif.ogv -vo jpeg:outdir=/home/miki/Videos/img_mygif

It will play video and start the process, at the end of witch we will have images in the ~/Videos/img_mygif directory. You can enter that directory and delete some of the images on start and the end in order to make GIF shorter.

To create actual GIF, we need to use imagemagick to fuse images back together in GIF format. It is very resource intensive task, it can throw down to knees even most powerful ones of machines, so we will use options to limit usage of resources, which will in turn make the process take more time. But at least you wont end up with completely unresponsive system.  The options for limiting are -limit memory 1 -limit map 1

convert -limit memory 1 -limit map 1 /home/miki/Videos/img_mygif/* final.gif

In order to make the gif smaller we can optimize it

convert -limit memory 1 -limit map 1 final.gif -fuzz 10% -layers Optimize final_optimzed.gif

And here is the final GIF:

gtk recordmydesktop animated gif

Using Byzanz to make GIF

Byzanz is another software which can greatly simplify the creation of the GIFs. First, off course we need to install Byzanz.

sudo apt install byzanz

We can right away start by making a GIF

byzanz-record --duration=5 --x=500 --width=250 --height=100 newgif.gif

Byzanz animated gif

The most challenging part here is actually fitting the right area of the screen to capture. The options width and height need to be tested several times before you get the right alignment. Here are the options and the syntax of byzanz-record command:

miki@miki-X550JK:~$ byzanz-record --help
Usage:
byzanz-record [OPTION...] record your current desktop session

Help Options:
-?, --help Show help options
--help-all Show all help options
--help-gtk Show GTK+ Options

Application Options:
-d, --duration=SECS Duration of animation (default: 10 seconds)
-e, --exec=COMMAND Command to execute and time
--delay=SECS Delay before start (default: 1 second)
-c, --cursor Record mouse cursor
-a, --audio Record audio
-x, --x=PIXEL X coordinate of rectangle to record
-y, --y=PIXEL Y coordinate of rectangle to record
-w, --width=PIXEL Width of recording rectangle
-h, --height=PIXEL Height of recording rectangle
-v, --verbose Be verbose
--display=DISPLAY X display to use

Using peek to make GIF

Peek is great piece of software that enables you to quickly record GIFs by selecting and recording piece of screen. To get peek

wget https://github.com/phw/peek/releases/download/v0.7.2/peek-0.7.2-Linux.deb

To get dependancies

sudo apt install libsdl1.2debian ffmpeg

Installing the package

sudo dpkg -i peek-0.7.2-Linux.deb

And start the peek

peek

It will give you frame like this

peek Frame

You can easily use this frame to get piece of the screen and record GIF there. For example I will Peek into terminal again.

Peek animated gif

Conclusion

There we have three ways to make animated GIFs in Ubuntu. First method, using imagemagick, is also useful if you have video from internet, ie, not made by yourself. Second and third method rely on you making the screencast on your computer. You can pick methods based on your needs and preference, and generally all three can get you the same result. This was all for today's article, thank you for reading.

Filed Under : OPEN SOURCE TOOLS

Tagged With : ,

Free Linux Ebook to Download

Comments (4)

Trackback URL | Comments RSS Feed

  1. Song says:

    Will imagemagick work in Ubuntu 16.04?

  2. James Van Damme says:

    I tried to make a gif out of several pictures that I shot in rapid succession. I used Gimp, which makes it easier to crop them to the same area and then make the animation. But for some reason the output was low color depth, which looked terrible on a photo.

    • Mihajlo Milenovic says:

      I had similar problems now and then, but I found out that Peek is most trouble free of above. There is also java based ScreenStudio, but haven't been able to make it work.

      I dont have solution for that problem other than switching software and trying what works best.

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.