How to create GIF Images in Ubuntu

To create GIF Images On Ubuntu

GIF Images are the animated images. GIF Stands for Graphical Interchange Format. In order to develop a GIF Images, install FFmpeg and ImageMagick packages. FFmpeg is used as an audio and video converter whereas ImageMagick is used to create, edit, combine bitmap images.

To install FFmpeg and ImageMagick packages

Run the following command to install FFmpeg and ImageMagick packages.

root@linuxhelp:~# apt-get install ffmpeg imagemagick -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
imagemagick is already the newest version (8:6.8.9.9-7ubuntu5.1).
imagemagick set to manually installed.
The following packages were automatically installed and are no longer required:
  libpango1.0-0 libpangox-1.0-0 linux-headers-4.4.0-21 linux-headers-4.4.0-21-generic linux-image-4.4.0-21-generic linux-image-extra-4.4.0-21-generic
.
.
.
Setting up libvdpau1:amd64 (1.1.1-3ubuntu1) ...
Setting up ffmpeg (7:2.8.6-1ubuntu2) ...
Setting up libaacs0:amd64 (0.8.1-1) ...
Setting up libbdplus0:amd64 (0.1.2-1) ...
Setting up mesa-vdpau-drivers:amd64 (11.2.0-1ubuntu2) ...
Setting up i965-va-driver:amd64 (1.7.0-1) ...
Setting up vdpau-va-driver:amd64 (0.7.4-5) ...
Setting up va-driver-all:amd64 (1.7.0-1) ...
Setting up vdpau-driver-all:amd64 (1.1.1-3ubuntu1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...

To create GIF from Video file

Create GIF images from a video file by using the following command.

root@linuxhelp:~/Desktop# ffmpeg -ss 00:00:00 -i intro.avi -to 00:00:40 -r 3 -vf scale=200:-1 intro.gif
ffmpeg - command which converts video format into GIF
-ss - To set Starting point from video to create GIF
-i - input file name here in my case “ intro.avi”  
-to - Ending point from video to create GIF
-r - frame rate
-vf - To set the required size for the GIF image
root@linuxhelp:~/Desktop# ffmpeg -ss 00:00:00 -i intro.avi -to 00:00:40 -r 3 -vf scale=200:-1 intro.gif
ffmpeg version 2.8.6-1ubuntu2 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.1 (Ubuntu 5.3.1-11ubuntu1) 20160311
  configuration: --prefix=/usr --extra-version=1ubuntu2 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-
.
.
.
Stream mapping:
  Stream #0:0 ->  #0:0 (tscc2 (native) ->  gif (native))
Press [q] to stop, [?] for help
frame=   15 fps=0.0 q=-0.0 Lsize=     130kB time=00:00:05.00 bitrate= 212.6kbits/s dup=0 drop=128    
video:129kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.697944%

After creating GIF open it.

To Create GIF from Image files

In order to get GIF form of images, combine two or more images by running the following command.

root@linuxhelp:~/Desktop/GIF# convert -delay 120 -loop 0 *.jpg linuxhelp.gif
root@linuxhelp:~/Desktop/GIF# ls
1.jpg  2.jpg  3.jpg  4.jpg  5.jpg  6.jpg  7.jpg  8.jpg  9.jpg  linuxhelp.gif

Now the GIF is created, view it by opening from GUI.

Tag : ImageMagick
FAQ
Q
How to install FFMPEG and Imagick in Ubuntu?
A
To install FFMPEG and Imagick in Ubuntu use "apt-get install ffmpeg imagemagick -y".
Q
What are the packages involved in GIF Image formation?
A
The packages involved in GIF Image formation are FFMPEG and Imagick. FFmpeg is used as an audio and video converter whereas ImageMagick is used to create, edit, combine bitmap images.
Q
In ubuntu 15.04 what is the .deb repository for Imagick?
A
No need of the .deb repository for Imagick, just simply update the available repository and install.
Q
How to create GIF from other file formats?
A
To create GIF from other file format sysntax is as follows "ffmpeg -ss 00:00:00 -i intro.avi -to 00:00:40 -r 3 -vf scale=200:-1 intro.gif"
Q
Will it be easy to create gif from image files ? If so how?
A
Say for example this is the example provided convert -delay 120 -loop 0 *.jpg linuxhelp.gif