GIF Compression and Optimization
GIF is a popular file format for images that have less than 256 colors. To minimize image file size it uses LZW data compression algorithm. VIMAS Technologies supports GIF file format in image optimization utility Web Image Guru and in software development kit VIMAS Imaging SDK. Below briefly described GIF optimization parameters available in these VIMAS products.
1. Color reduction.
Since GIF images may contain 256 or less colors and real life images contain millions of colors, the number of colors should be reduced. VIMAS Technologies offers extremely effective color reduction algorithm that outperform most known rivals. It produces consistent, quality results even for 16 colors images. You may choose one of several available algorithms (perceptual, adaptive, grayscale, etc.) and set any desired number of colors (2-256). You may estimate the quality of the VIMAS color reduction in the pictures below or examine more examples here.

Fig.1 High quality JPEG image
9702 Colors
|

Fig.2 Web Image Guru GIF
File size 4.97 K, 47 Colors,
Dither 0, Lossy 0
|
2. Dithering.
As you may see from Fig.2 color reduction on smooth image areas cause banding that drastically affect image quality. To reduce it should be used dithering, which spatially mix adjacent colors to simulate removed colors. Unfortunately dithering may lead to increased file size, false colors and structured noise. Such artifacts are fairly visible on the Fig.3, which is created by Adobe Photoshop CS. There are 2 false color pixels at the right top corner, and structured dithering noise (darker and lighter lines) at the left of them. Image created by Web Image Guru has more random dithering pattern without false colors, which is more pleasured for human eye.

Fig.3 Adobe Photoshop CS GIF
File size 7.17 K, 29 Colors,
Dither 100%, Lossy 0
|

Fig.4 Web Image Guru GIF
File size 6.80 K, 47 Colors,
Dither 7, Lossy 0
|
3. Lossy GIF compression.
Lossy GIF compression is a feature that permits some spatial artifacts (losses) in image to improve compressibility of GIF files. Like with dithering, it is better for human eye if algorithm’s artifacts have random, dot level structure. And on Fig.5 and 6 you may compare results obtained with Adobe Photoshop CS and Web Image Guru respectively.

Fig.5 Adobe Photoshop CS GIF
File size 7.10 K, 256 Colors,
Dither 100%, Lossy 33
|

Fig.6 Web Image Guru GIF
File size 7.16 K, 256 Colors,
Dither 7, Lossy 22
|
4. Weighted GIF optimization.
GIF weighted optimization lets you improve quality (reduce compression ratio) only for the important masked regions. This technique produces higher-quality results in critical image areas without sacrificing file size. Fig.7 shows the using of dithering only on the top-right part of image. Image looks like one from Fig.4, but has 15% smaller size. Images on Fig.6 and 8 have the same size, but on Fig.8 lossy artifacts reduced in top-right corner and increased in the remained area.

Fig.7 Web Image Guru GIF
File size 5.9 K, 47 Colors,
Dither 0, Lossy 0, Extra Dither 70%
|

Fig.8 Web Image Guru GIF
File size 7.16 K, 256 Colors,
Dither 7, Lossy 22
|
5. Alpha Dithering.
GIF files may contain only fully transparent and fully opaque pixels; therefore Alpha Dithering is used to simulate partial transparency. As you may see from images below (created by Web Image Guru), alpha dithering significantly improve image appearance over unspecified background. Image from Fig.12 has much smoother transition from blue to brown, than one displayed on Fig.11.

Fig.9 No alpha dithering
Predefined background
|

Fig.10 Alpha dithering 8
Predefined background
|

Fig.11 No alpha dithering
New background
|

Fig.12 Alpha dithering 8
New background
|
VIMAS image processing technologies:
For questions & comments please contact info@vimas.com or visit our forum
|