In a previous post I mentioned choosing the right file format as one of the 6 key factors in optimizing images for the web. I’m now going to give you more pointers to help you decide which file format is the best choice depending on the graphic you are dealing with. I will focus only on the three most common graphic file formats used in web design: JPEG, GIF and PNG.
It is the most appropriate export format for graphics with large areas of solid colors. Digital artwork using a narrow palette of colors (up to 256) will deliver crisp and a small file size when exported as a GIF.
The GIF format is also a good choice to make certain colors transparent in the exported image: index transparency. That comes handy when you need transparent edges around your image. You will be then able to blend that exported image with any web page area no matter what background color is used.
Your only choice is a GIF format to create animated graphics such as banners (animated gif) unless you use a Flash movie: JPEG and PNG do no supports a such animations. You would have to either keep the number of animation frames to a minimum and reduce the dimensions (width and height) to lower the file size of your “animated gif”.
This format is more appropriate for images with lot of details and photos requiring millions of colors. The JPEG format is also the best option for computer graphics with gradients of colors or artworks using shadows, bevel, feather and other digital effects.
Images exported in a JPEG format are usually crisp when exported with a compression between 60 and 80%. That gives you enough wiggle room to find a balance between quality and file size.
The PNG format comes in three flavors: PNG8, PNG24 and PNG32. This format lays somewhere between the GIF and JPEG formats. PNG is a lossless compression, uses virtually unlimited palette of colors and offers both index and alpha transparency.
Let’s explore what each subset of this format has to offer.
- The PNG8 is quite similar to the gif format in terms of quality and size of the exported file. It offers index transparency as well as alpha transparency
- PNG24 is better suited when your graphic is a mixture of lots solid colors and gradients. In a nutshell, the png24 format lays between the gif and jpeg formats. It produces crisper images with a smaller file size than the GIF format. However the PNG24 does not offer index or alpha transparency.
- The PNG32 option is currently not available in Photoshop. You will have to use Adobe Fireworks to take advantage of the full alpha transparency offered by the PNG32 format.
- The only drawback of PNG images is they are not well supported by Internet Explorer 6: you will have to resort to a CSS hack using Microsoft’s filters.
- Although the GIF format offers a palette of 256 colors, my personal experience taught me to use the GIF format only when no more than 32 colors are needed to keep the exported image sharp. For images requiring more colors, you are better off using the other file formats.
- If the image you are dealing with needs more colors than the GIF format can handle and no transparency is required then JPEG is your best bet.
- There is no real gain in choosing the PNG format at this point unless you are using the PNG32 to take advantage of alpha transparency you cannot get with GIF or JPEG format.
In the end there are really no hard rules in choosing the right file format to export your image in. As you just learned, the best suited file format depends on the current context: the graphic you are working on.