How to compress the image using gifsicle tool or any other tool on ubuntu

Gifsicle's --optimize option will only attempt lossless reduction of an image's file size. What you probably have* is an animated gif where each frame contains random dithering, so most of the pixels will change from one frame to the next.

If your original GIF image had used pattern dithering, you would be able to compress it a lot more. But if that's not an option, I suggest you try either reducing the dimensions of the image (e.g., --scale 0.5), or reducing the number of colours in it (e.g., --colors 16).

* (I'm only guessing, since you didn't bother to share your image)


UPDATE:

The giflossy fork has been merged into gifsicle now, so you will be able to use the --lossy flag with gifsicle now (with the latest version), no need to install giflossy separately.


If you want to enable lossy compression which reduces the size considerably, you can use giflossy fork of gifsicle. Once you have installed it you can use the lossey option as below

 gifsicle -O3 --lossy=80 gifimage1.gif -o new-gifimage1.gif

Installation:

  • On Mac : brew install giflossy
  • On Unix : Building Gifsicle on UNIX

You can use below command to tweak your compression options

 gifsicle -O3 --colors=64 --use-col=web --lossy=100 --scale 0.8  gifimage1.gif -o new-gifimage1.gif