The gifsicle is a command line tool that allows to create, edit, optimize, retrieve information, and perform other operations with GIF images.
This tutorial demonstrates how to install gifsicle on Raspberry Pi.
Use SSH to connect to Raspberry Pi. Then update the package lists and install gifsicle with commands:
sudo apt update
sudo apt install -y gifsicle
We can check gifsicle version:
gifsicle --version
Now download image from the Internet for testing:
wget -O test.gif https://raw.githubusercontent.com/snipe/animated-gifs/master/hiding/cat-hides-in-couch.gif
The gifsicle has -O
option that enables to optimize the GIF images. There are three optimization levels: -O1
(default), -O2
, and -O3
. The higher optimization level is slower but sometimes provides better results. The -o
option is used to specify the output filename.
gifsicle -O3 test.gif -o result.gif
We can check the image sizes:
ls -l
-rw-r--r-- 1 pi pi 971453 Mar 6 05:15 result.gif
-rw-r--r-- 1 pi pi 1025400 Mar 6 05:14 test.gif
After optimization an image is ~5% smaller than the original image.
We can also minimize the image size by reducing the number of distinct colors. The number of colors can be specified between 2 and 256 by using --colors
option.
gifsicle -O3 --colors 128 test.gif -o result.gif
If gifsicle is no longer needed, you can remove it by using the following command:
sudo apt purge --autoremove -y gifsicle
Leave a Comment
Cancel reply