How to create GIF from images using ImageMagick

ImageMagick is truly a magical tool for images. It makes it super-easy to create an animated GIF file from a series of image files.

To create an animated GIF from 3 input images with a delay of 2 seconds between each frame and loop infinitely:

$ convert -delay 200 -loop 0 1.png 2.png 3.png out.gif

Tried with: ImageMagick 6.8.9.9 and Kubuntu 16.04

How to screen capture a region to GIF using Byzanz

Byzanz can be used to screen capture and save it to an animated GIF file. To capture a region of the display, you can pass it the XY coordinates of the top-left corner of the region and the width and height of the region. A more intuitive method would have been to draw a region on the display and have Byzanz capture that.

Thanks to Rob W, you can do that using his Bash script byzanz-record-region, which can be found here. Getting this to work takes a few steps:

  • Install Byzanz as described here.

  • We need a tool to mark a region of the display. xrectsel is one such tool and it available with FFcast2. Clone its repository and build the tool:

$ git clone https://github.com/lolilolicon/FFcast2.git
$ cd FFcast2
$ make

Move the xrectsel binary to location accessible from your PATH.

  • Create a Bash script file from the source code for byzanz-record-region available here.

  • That is it! To record or screen capture a region of the display for 10 seconds, just invoke the script without any parameters:

$ byzanz-record-region

Your mouse cursor turns into a cross-hair. Draw the region on the display. A countdown of 10 seconds is shown followed by a beep. Recording begins and ends after 10 seconds. You can find the resulting animated GIF file in /tmp/recorded.gif.

  • To provide a different duration of recording or filename, you need to provide both parameters (even if you only need to change one of them):
$ byzanz-record-region 30 foobar.gif

Tried with: Ubuntu 12.04

How to screen capture to GIF using Byzanz

Byzanz is a command-line tool that can be used to screen capture and save it to an animated GIF file.

To install Byzanz on Ubuntu, add the PPA and install the package:

$ sudo add-apt-repository ppa:fossfreedom/byzanz
$ sudo apt-get update
$ sudo apt-get install byzanz

You capture using the command byzanz-record. By default, it captures for 10 seconds. For example:

$ byzanz-record foobar.gif

To add a delay of 5 seconds before starting the screen capture:

$ byzanz-record --delay=5 foobar.gif

Tried with: Byzanz 0.3.0 and Ubuntu 12.04