How to compress GIF animations? For example by reducing the color index.
The files are generated using Imagemagick but optimization seems complicated.
For example, the following animation is 864KB at 150x119:
To be used on a Linux machine.
How to compress GIF animations? For example by reducing the color index.
The files are generated using Imagemagick but optimization seems complicated.
For example, the following animation is 864KB at 150x119:
To be used on a Linux machine.
Use gifsicle (available for Mac OS X, Windows, DOS, Debian, FreeBSD and NetBSD).
gifsicle -i anim.gif -O3 --colors 256 -o anim-opt.gif
This will optimize and reduce to 256 colors, if the animation uses more colors (the example image does).
You can reduce the size by reducing the number of colors:
Based on another Q&A.
gifsicle -i anim.gif --optimize=3 -o anim-opt.gif
Nov 21, 2017 at 12:50
Small addition to @qubodup's answer
Add --lossy
flag. This flag varies from 30 to 200, where 30 is good enough.
gifsicle -O3 --colors 256 --lossy=30 -o output.gif input.gif
gifsicle
that comes with Ubuntu 18.04 does not have the --lossy
feature. If I look at the bottom of man gifsicle
I see it is version 1.91 from 11 July 2017. The version that comes with Ubuntu 20.04, however, does have the --lossy
feature. The bottom of its man page shows it is version 1.92 from 11 July 2017. gifsicle --version
on Ubuntu 18.04 shows LCDF Gifsicle 1.91 Copyright (C) 1997-2018 Eddie Kohler
. From Ubuntu 20.04 it shows LCDF Gifsicle 1.92 Copyright (C) 1997-2019
. Again, version 1.91 does not have the --lossy
feature, but version 1.92 does.
Jan 11, 2022 at 15:21
NEWS.md
file here confirms that --lossy
was added with Version 1.92.
Jan 11, 2022 at 17:32
-O3 --lossy
. Rather than decreasing file size, filze size actually increased by a tiny amount of about 0.3%. Furthermore, the file sizes were exactly identical for me for both -O3 --lossy=30 --colors 16
and -O3 --lossy=100 --colors 16
, as well as for -O3 --lossy=30 --colors 256
and -O3 --lossy=100 --colors 256
. In other words, whether lossy was set to 30
or 100
seemed to have no difference in my cases whatsoever, for the file I tested at least.
Jan 11, 2022 at 17:35
ffmpeg
answers superuser.com/a/1695537/1076303