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 you'll 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. Dobb's 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 King's web site to learn the best Web Site Optimization practices for higher traffic and speed guaranteed. www.websiteoptimization.com
![]() |
|
![]() |
|
![]() |
|
![]() |
No matter the size of your business, having a web... Read More
It is an undeniable fact that not everybody is keen... Read More
Every small business owner knows that they need a website,... Read More
If you don't have a web site yet, are thinking... Read More
This simple question can take on several different forms, but... Read More
Optimal website design is the art of logical navigation.It will... Read More
Fresh website content for your visitors can be of real... Read More
Spend time planning your Web site. Before you design a... Read More
If you're looking for better web site ROI, chances are,... Read More
Losing website sales and traffic is sometimes simply a case... Read More
If you ever want to create a state directory, article... Read More
In the big, wide online world there are millions of... Read More
Failure, just like success, is measured differently by each and... Read More
Your web site will be your window to the world.... Read More
Absolutely everything stems from the purpose of your website -... Read More
We are clearly well past the innocent "golden age" of... Read More
Making maximum profit from your law firm website is important,... Read More
Did you know that hosting companies overcrowd their servers despite... Read More
The following is a list of patterns that many visitors... Read More
First, an eye opener. Making your fortune through affiliate programs... Read More
Every business needs to know how it is doing. That's... Read More
I've heard several prominent web marketers mention in their classes... Read More
Every good Internet business understands the value of conversions versus... Read More
You've put up a website to promote a product or... Read More
When visitors add your web site to their Favorites or... Read More
The Internet is a remarkable publishing medium. With just a... Read More
Dance is how you pamper your soul and satiate your... Read More
What do you mean, you don't have a website for... Read More
Alternate medicine finds its own place in the hearts and... Read More
Building a new website can be a lengthy task. From... Read More
So you want to have a website. You have gone... Read More
From early days of www, the Internet sites that are... Read More
Design and layout can make your communication come alive and... Read More
This simple question can take on several different forms, but... Read More
When building a relationship, listening is more important than talking.A... Read More
How do you decide on the content, products and or... Read More
1) Data CaptureOne easy way to collect e-mail addresses and... Read More
A simple website stats counter is not enough if you... Read More
Recently I was reviewing the keyword specific conversion rate data... Read More
Optimal website design is the art of logical navigation.It will... Read More
Developing a website with content that entices visitors to return... Read More
Every good Internet business understands the value of conversions versus... Read More
Understanding and using web analytics.In recent years, website marketers were... Read More
Creating and maintaining an effective presence on the Web has... Read More
SummaryHere's the scoop on what you must know when designing... Read More
When visitors add your web site to their Favorites or... Read More
#5 User Satisfaction: Learn what your visitors and site users... Read More
So you have a good idea for a business and... Read More
I'm one of those people that always wanted a website,... Read More
"I don't sell anything online, I don't advertise online, in... Read More
Just starting out, you can start with a simple informational... Read More
In about the Time it takes to Watch a Reality... Read More
Huge Mistake #1: Creating a Website with Flash -- Did... Read More
1. Many people are not getting good or complete advice.... Read More
How can we add Word Rich Content to our Websites... Read More
The growth in Internet usage around the world is astounding... Read More
In the region where my company is located, South Bend,... Read More
Web templates by nature are created to aid and ease... Read More
Having an eye catching website is great, but are you... Read More
Do you make your website just to entertain yourself or... Read More
One of the things that Internet excels is disseminating information... Read More
If your company own one or more stores, you might... Read More
Running an effective website is a continuous process. I have... Read More
While it may seem like a "quick and easy" task,... Read More
For years now I've been looking to start my own... Read More
D.zigns dzignerwebs The Basics Before starting on... Read More
Web Development |