22

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
Penkey Suresh
  • 5,816
  • 3
  • 36
  • 55
anand
  • 1,711
  • 2
  • 24
  • 59

2 Answers2

43

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:

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
Penkey Suresh
  • 5,816
  • 3
  • 36
  • 55
28

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)

r3mainer
  • 23,981
  • 3
  • 51
  • 88
  • I have share the image too, if it can be reduced to more than 20% it will be fine for me, since in our application we have large collection of images coming dynamically from every user of this application – anand Apr 11 '14 at 09:57
  • @anand [Reducing the number of colours to 8 results in a file that's about 44% smaller.](http://imgur.com/M3onA4s) If you want to go further, get rid of the dithering and/or antialiasing in the source images. – r3mainer Apr 11 '14 at 11:23
  • yeah i tried your option --colors 16 and it reduced the filesize by 19% but when i tried this option for other images the image quality drastically reduces since they are using more no of colors. Is there any other option or any other tool than gifsicle which can give me better results. – anand Apr 12 '14 at 05:47
  • 3
    @anand In my experience, gifsicle produces the best compression, but ImageMagick does a very good job of producing images that are more compressible. In general, I'd suggest using the latter to produce an animated gif from clean 24-bit source images (e.g., `convert *.png -ordered-dither o8x8,8,8,8 -delay 5 animation.gif`), then optimize the results with gifsicle (`gifsicle -b -O3 animation.gif`). But there really is no magic technique that will work with all images, so be prepared to experiment. – r3mainer Apr 12 '14 at 18:38