Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Image to be compressed . filesize : 669kb I have some images in .GIF format which i want to compress. But i am getting the output either same or hardly 2-5% compression.I need higher compression ratio so that the web pages can be loaded fastly. Currently i am using the gifsicle tool but hardly i am finding much difference in size of the generated gif images. I opted this tool from yahoo smush it.

 gifsicle -O3 gifimage1.gif -o new-gifimage1.gif
like image 671
anand Avatar asked Apr 11 '14 09:04

anand


2 Answers

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
like image 158
Penkey Suresh Avatar answered Nov 04 '22 14:11

Penkey Suresh


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)

like image 20
r3mainer Avatar answered Nov 04 '22 14:11

r3mainer