Install gifsicle on Ubuntu 22.04

Install gifsicle on Ubuntu 22.04

The gifsicle is a command line tool that can be used to create, edit, optimize, retrieve information, and perform other operations with GIF images.

This tutorial shows how to install gifsicle on Ubuntu 22.04.

Install gifsicle

Execute the following command to update the package lists:

sudo apt update

Next, install gifsicle:

sudo apt install -y gifsicle

When installation is completed, we can check version of gifsicle:

gifsicle --version

Testing gifsicle

Download image for testing:

wget -qO test.gif https://raw.githubusercontent.com/snipe/animated-gifs/master/hiding/cat-hides-in-couch.gif

The gifsicle command allows specifying -O option to optimize the GIF images. The command supports three optimization levels: -O1 (default), -O2, and -O3. The higher optimization level is slower, but sometimes provides better results. The -o option allows providing the output filename.

gifsicle -O3 test.gif -o result.gif

You check the image sizes as follows:

ls -l
-rw-rw-r-- 1 adminer adminer  971453 Jan 12 03:13 result.gif
-rw-rw-r-- 1 adminer adminer 1025400 Jan 12 03:13 test.gif

As we can see, after optimization, an image is ~5% smaller than the original image.

The image size can also be minimized by reducing the number of distinct colors. Using the --colors option, we can specify the number of colors between 2 and 256.

gifsicle -O3 --colors 128 test.gif -o result.gif

Uninstall gifsicle

If gifsicle is no longer necessary, it can be removed with command:

sudo apt purge --autoremove -y gifsicle

Leave a Comment

Cancel reply

Your email address will not be published.