Search

Change Language

Friday, May 13, 2011

Which Image Format is Best

This was originally posted on YourTotalSite on June 10, 2005
When developing a web site you may not think much about what image format you use but you could end up saving yourself or your organization a chunk of change in bandwidth costs by making your choice more wisely. On the web today there are three main image format types to choose from and all have their advantages and disadvantages. You have a choice of three different compressed image formats: GIF, JPEG or PNG. They each use different techniques to compress the image information.

GIF

GIF uses a lossless compression which means that no quality is lost in the compression. The uncompressed image stores its information in a linear fashion. Each line of pixels is read from left to right. An interlaced GIF file stores the lines of the image in a different order. First lines 4, 8, 12, 16 and 20 may be read in. Then lines 2, 6, 10, 14, and 18 and so on until the entire image is read. When the image is read in this way, a user with a slower internet connection may be able to understand or read the image before it has fully loaded.
The GIF format achieves its compression by removing repeated patterns within the GIF file and storing references to these sections in a list, also known as a hash. Images with horizontal lines of the same color or pattern benefit most from the GIF format. This would include images like background graphics, images with text and patterned images.
Another great advantage is the ability to create animated images. You’ve no doubt seen them throughout the internet. Especially if you were around for the heyday of the 90’s! An animated GIF is essentially a sequence of GIF files with some timing information included. Animated GIFs, however, can run into large file sizes awfully quickly and with very few frames of animation. While it may be a fairly ubiquitous format, if you have to do animation, you may be better off going with Macromedia Flash. If one frame is 15KB then 20 frames could suddenly find you well over 100KB just for one animated image.
Another advantage to GIF files is transparency. A color within the color table can be selected as the transparent color. In doing so, wherever that color occurs, you’ll be able to see through to the HTML background. One of the largest downfalls to the GIF format is its inability to have a color palette of more than 256 colors. This can create poor looking images when used on a photograph which may originally have thousands of different colors.

JPEG

JPEG uses a lossy compression which means that image quality is lost in the process of compressing the image. JPEG compression works by first converting the image from RGB to YUV which stores information about each pixel using brightness, hue and saturation. Then it reduces the amount of information it stores for hue and saturation since differences are less noticeable to the human eye. In trying to decrease the file size of the JPEG (for example, when using the quality slider in Photoshop), you'll tend to notice artifacts occur in flat color areas and especially near edges. As a result, JPEG is best used for images that have more of a variation in colors. For example, images with gradients or photographs can handle a lower quality setting with little noticeable loss in quality. Images with text or large solid backgrounds are best left for GIF or PNG.

PNG

PNG is the relative newcomer to the list of available image formats and it is a formidable one. It is similar to GIF in many ways but even better in others. It is lossless like GIF but supports 24 bit color, unlike GIF which only supports 8. PNG supports alpha transparency, whereas GIF only supports one-color transparency. PNG uses various compression filters to minimize overall image size and can apply different filters on a per-line basis to achieve higher compression. The big attraction to PNGs is its ability to do alpha transparency. Unfortunately, Internet Explorer currently doesn't have full support for it, although there are hacks out there that can pull it off.
If you are not using alpha transparency or do not need more than 256 colors then exporting as an 8-bit PNG is the way to go. On average, 8-bit PNG will be smaller in file size than GIF with absolutely no difference in image quality. PNG and GIF are also very similar in that they both work better with large lines of the same pattern or color. If you do not need alpha transparency but wish to use a color palette greater than 256 colors then you are looking at a 24-bit PNG. It'll be important to test between a 24-bit PNG and JPEG to see which achieves better results. PNG still suffers the same problem as GIF in that they cannot optimize photographs as well as JPEG can.

Is there a winner?

No format is best in all scenarios. Therefore, it's always best to play around with the various formats and compression levels to achieve the best results.
If you'd like to learn more on the history or inner workings of these file formats, be sure to check out the Wikipedia entries on GIF , JPEG , and PNG .

Amazon launches Simple Email Service

Amazon has launched a new API for sending email "in the cloud" called Simple Email Service.
Like other Amazon services, one of the biggest draws—besides using the solid infrastructure—is the pricing. You can send up to 2,000 emails a day absolutely free. After that, you're looking at 10 cents per thousand emails and 15 cents per GB of data transfer.
Some basic list management functionalities such as tracking bouncebacks and marked-as-spam are included but all other list management functionality is not. This is a simple API designed for people who wish to manage the process on their own and would be a great addition to those who are using other Amazon Web Services.
My first question was, "How do they stop spammers?" Amazon scans each email before it goes out and if it has questionable data, they'll stop it from sending. Good to know.

Impact on the market

My next thought was, "What does CampaignMonitor and MailChimp think of this?" To be clear, SES is not a direct competitor to either of these services. CampaignMonitor and MailChimp provide plenty of tools and a great interface for managing email campaigns and lists.
My thought goes in two directions.
One, could or would these services shift any of their infrastructure to take advantage of the SES services. I could foresee an adjusted pricing structure and a spot where I could enter my AWS API key.
The second thought I had is related in that other services could pop up that are full management applications like CampaignMonitor and MailChimp but built on the SES service and possibly providing more cost effective solutions. I would not be surprised to see at least a couple services running within the next six months doing just that.
For more direct competition, you'd need to look at Postmark which, like SES, provides an API for you to integrate email services easily with your web application. That they have API code for a number of languages is already an advantage over Amazon's service.
It'll be interesting to see how the market evolves over the next year.