Web Site Optimization: How To Speed Up Your Web Site By Minimizing Your GIF and PNG Image "Bit-Depth"


Andy King

Web Site Optimization: How To Speed Up Your Web Site By Minimizing Your GIF and PNG Image "Bit-Depth"

Are bloated images slowing down your web site and causing you lost business Images comprise over 50% of the average web page so putting them on a diet is essential to improving web performance. One of the best ways to optimize GIFs and PNGs is to minimize the “bit-depth” or the number of colors within your images.

For palette-based formats like GIF and PNG, file size is directly related to the size of the color palette, or the number of colors in the image. As the number of colors in an image crosses a power of two, the file size jumps. A 33-color image must use a six-bit palette, while a 32-color image can use a 5-bit palette. Smaller palettes mean smaller codes representing pixel patterns, which makes for smaller files. So minimizing the number of colors in index-color images like GIFs and PNGs will minimize file size.

The compression schemes used in GIFs LZW and PNGs Deflate are dictionary-based encoding algorithms. Dictionary based compression algorithms substitute shorter codes for longer patterns of strings within the data stream. Pixel patterns substrings in the data stream found in the dictionary are replaced with a single code. If a substring is not found in the dictionary, a new code is created and added to the dictionary. Compression is achieved when smaller codes are substituted for longer patterns of data.

The code size is based on the number of bits per pixel, and depends on the maximum length code within your dictionary. Thus the smaller your bit-depth, the smaller the codes representing your pixel pattern strings, and the smaller the file.

Choosing the right format for your images is the first step in optimizing web graphics. At lower bit-depths, banding can appear in smooth-toned images. Try quantizing your image to different palettes to minimize banding.

PNG Compression

PNG uses the deflate compression algorithm which is a newer, more efficient cousin of LZW. Deflate is designed to be free of patent problems. Deflate is a combination of the LZ77 algorithm found in zip programs like WinZIP and gzip, and Huffman coding. Deflate typically compresses files 20 to 30 percent smaller than LZW, which is the difference youll find between gzip and compress. PNGs use a similar substitution technique, but are generally 5 to 25 percent smaller than GIFs, although there are exceptions. In addition to horizontal "scan-line" pattern substitution PNGs sometimes substitute for vertical patterns. PNG can also truncate color palettes. In general, the smaller the color palette, the smaller the overal file size.

Conclusion

To minimize the file size of palette-based image formats like GIF and PNG, minimize their bit-depth, or number of colors. Each time you pass a power of two, file size jumps higher. By minimizing the number of colors, and maximizing the flat-color areas you will create smaller, more efficient images destined for the Web.

Further Reading:

LZW Data Compression
http://www.dogma.net/markn/articles/lzw/lzw.htm
Mark Nelson breaks down the LZW compression algorithm for Dr. Dobbs Journal of October 1989.

Multimedia: Use Lossy Compression for Smaller GIFs and PNGs http://www.websiteoptimization.com/speed/tweak/lossy/
Lossy compression lets you squeeze more bytes out of your GIFs and PNGs. Lossy compression increases identical pixel patterns to improve compression in indexed-color images.

Multimedia: Use Weighted Optimization
http://www.websiteoptimization.com/speed/tweak/weighted/
Weighted optimization or regional compression applies different degrees of compression to different areas of your image. By varying the quality within images you can improve file size.

Optimizing Web Graphics
http://www.websiteoptimization.com/speed/12/
Chapter summary from Speed Up Your Site, shows how to correct, optimize, and compress images for minimum file size and maximum quality.

PNG Home Site
http://www.libpng.org/pub/png/
Greg Roelofs site devoted to all things PNG.





About The Author

Article by Andy King, author of the popular new book titled "Speed Up Your Site – Web Site Optimization". Visit Andy Kings web site to learn the best Web Site Optimization practices for higher traffic and speed guaranteed. www.websiteoptimization.com



To provide some examples of web design and development I give you here:

10 latest blog posts by Web Developer Jim Westergren

I’m an SEO and I have been working a lot with WordPress, here I give you all my tips for you to rank very well in Google with your blog. UPDATE: Check this blog post for a better guide. Quick Facts There are 55 million blogs out there, if you don’t stand out you will have no chance. The [...]

Update, March 9th I have now changed it again and put some color into it. What do you guys think? Sunday today and I was away from work with clients so I decided to work with my blog today from home. I made a new design for this site. Check out the navigation links at the top left [...]

This article is written for my friend “honey” (site). I have been bidding against honey on web site auctions for almost 2 years now. I have won maybe 60 auctions and I have now over 100 web sites. Honey owns over 300 … So here comes my checklist that I want to show honey as I [...]

Have you also heard of those horror stories of Google banning Adsense accounts for the smallest mistakes? You have read the Terms and Conditions and you know the basics but what do you do when you show your friend your site on your computer and the first thing he does is to click the Adsense ad [...]

This article is written more for myself so I remember how I do it the next time but probably a few people will also benefit from this for different uses and purposes. Today I updated all the PR values for the directories listed on my directory list. I had to update each listing in the MySQL [...]

Official site of a children’s hospital in Japan Hey, your “logo” is not blinking! MSY Technology Pty. Ltd. Are you sure product X is HOT? Personal site of Franz Magnus Incredible that you got several awards for that site. Angren.net, electronic shop Can’t you squeeze in something more on the home page? Official site of Northbridge Police Department Still being updated in 2006. Perhaps [...]

The last days I have been fighting in the war against the latest spam bot soldiers like a maniac. I own and manage over 70 web sites. This includes different forums, directories, blogs, topsites, article submission sites and you name it. Very recently there is a new wave of spam. The default captcha for vBulletin is now [...]

This is a WordPress plugin that will give you more links and higher rankings in the search engines. Most bloggers knows the importance of getting links in order to get high rankings in search engines. But did you know that the best links are those that are natural recommendations? Additionally I experienced better rankings across all [...]

To improve the navigation of your users as well as search engine traffic and ranking to your WordPress blog I suggest making a good site map of your posts - a map of your site. A kind of user friendly archive of your posts. This is not “Google sitemap”! The benefits: The user can quickly find a [...]

How I rank on different keywords and links to the different SE queries.

home | site map

Articles



Debt Consolidation | Loan | Secured Loans | Car Credit | Mobile Phone