Webmaster Papers








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 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

RELATED ARTICLES


Let Your Customers Redesign Your Website!
When you purchase a new item from a Yahoo! Store, you are asked if you'd like to provide feedback on the transaction. About two weeks after the initial purchase, an email from Yahoo! Stores shows up, asking you to provide feedback for the vendor. Whether your experience was good or bad, the opportunity is probably seized more often than not by customers.
Website Sales: 10 Reasons Why People Dont Buy From You
You've put up a website to promote a product or service.
Revealing the Firefox Secret Used by Top Web Developers and Power-Browsers
Profiles are one of the best kept secrets around regarding Mozilla Firefox (my browser of choice).
I Want To Be A Freelancer
So you have decided that you want to do freelance work. You have done your homework and have developed your skills in HTML, PHP, CMS, and a slew of other applications. Now you are ready to start your new career. So how do you get started? Without clients your business is non existent. So how exactly do you build your business and find clients. Below are just a few key elements to help you get started.
Planning Your Website for Success
Most people know they need a website in order to publicise and promote their business but very few people know what they want in their website. Fewer still are those who can actually sit down and plan their websites well.
How To Convert More Sales On Your Website
One of the biggest mistakes that most online retailers make is they do not take into account typical buyer behaviour. The conversion from real world to online provides many benefits to the retailer, but present some real challenges for the customer because their buying decision is made more difficult in an online environment.
PHP Redirect
A PHP Redirect automatically transfers a web user from one URL to another. For example, typing foo.com in the browser automatically transfers the user to another URL bar.com.
Frequent Business Question: How Do You Start a Web Business?
Today it seems everyone is jumping on the entrepreneur bandwagon, and who could blame them? Setting your own schedule, working from the comfort of your own home, and never having to deal with a horrible commute or office politics again, this option is quite popular among all ages. With the advent of the technology age, it seems more individuals are looking to the internet to provide them with goods or services. Without having to leave your computer to shop for whatever your heart desires, web businesses have boomed over the past decade. More popular than ever, starting your own web business is an excellent way to earn an extra income or replace your current income. However, many individuals who wish to begin this new chapter in their lives do not have any experience in starting or running a business, spurring them to ask the question: how do you start a web business? The answer is: easy! All you need is a computer, internet connection, and a dream and you are halfway there.
Credibility - 10 Ways to Build it on Your Website
If you have your own business website and you are trying to sell something, then it is imperative that you are able to establish and maintain credibility. Why is this important? If you are going to ask someone to make a purchase from you, then you need to show them why they should purchase from you rather then your competitor on another site.
Top 5 Webmaster Tools You Can Pick Up For Pennies
1. SiteSpinner V2 - On Sale www.deprice.com/sitespinner.htm
Learn to Build a Better Online Business Website Using Keywords and Content
Are you aware that 90% of the websites on the Internet today are a waste of time and space. You have probably been on some of the sites I am referring to. You know the ones that when you arrive it really has nothing to do with your search criteria.
You Need a Website!
No matter the size of your business, having a web site is a low cost way to market your services and products twenty-four hours a day. Web sites are a constant advertisement for your business and will help you reach your targeted customers effectively. Your business will not be able to compete without a well-designed web site. There are several key elements to consider when you make the decision to start a new web site:
Getting One-way Inbound Links: the 5 Major Strategies
With search engines putting a damper on direct reciprocal links, the hunt for the elusive one-way inbound link is on.
How To Keep Your Website Sticky
Developing a website with content that entices visitors to return over and over again is something that takes time and effort to put together. This checklist can give you a great start on creating a popular website that entices readers to hang around on your site.
Non-Profits: Successful Online Strategies
More and more non-profit organizations are developing websites to help share information about their mission and programs. This involves strategic planning about the best way to present your image and message online. Once your site is up, your organization also has to be ready to keep information current and to maintain consistent outreach activities. If your group is planning a Web site, consider:
In Business? 10 Reasons Why You Need a Website -- Now!
1) Word of Mouth The single most powerful form of new business creation is word of mouth. Your past customers, friends, acquaintances and staff aren't likely to carry your brochure or even your business card everywhere they go. The can however carry your domain name, in their heads! Every time they have a conversation that leads to your kind of business they just quote your simple domain name. You've chosen a simple domain name of course, easily remembered, easily spelt and requiring no explanation. For that reason avoid hyphenated names.
Beware the Software Siren
I've heard several prominent web marketers mention in their classes and public forums how easy it is to create your own software. Why, all you have to do is run over to Elance.com or RentACoder.com and have some poor shmoe from Outer Slobvia whip out what you want. And all for the price of a few trips to Starbucks.
How To Start Your Own Website
I'm one of those people that always wanted a website, but had no clue as to using the internet. I could check my email and that was about it. I never heard of ISP, FTP or all those other "words".
What Your Customers Say About YOUR Site! Part 1
The following is a list of patterns that many visitors follow, and you can use these suggestions to better your site.
Increase Hits to Help Increase Your Business
In this day and age most businesses consider having their own website; from informational based to the most advanced and complex e-commerce site. For the large enterprise, this become a vital part of their day to day operation, their web site embeds complex applications that exchanges critical information between their partners and clients. Web services are sometime employed in order to simplify their transactions and easily exchange critical information across their suppliers, clients and partners.