RSS

Optimizing JPEGs


Optimizing JPEGs

One of the handiest things about JPEGs is that they allow you to control how hard the image gets hammered during compression. The quickest way to optimize a JPEG image is to increase the compression on the file. Given the nature of JPEGs, however, you can also brutalize the quality of an image by compressing it too harshly.

If you're trying to optimize a JPEG, experiment with different compression ratios. Typically, programs will talk about JPEG compression as "high/medium/low," or else as a percentage value. Unhappily, with some programs that use percentages, increasing the percentage value actually decreases compression, whereas with other programs, exactly the opposite is true. Make a copy of the original image to experiment on, and start exploring.

As you increase JPEG compression, many images will suffer unacceptable losses in display quality. Increase compression gradually (in increments of, say, 10%), until you find that image is truly suffering, then ease back up a bit. Again, this is an instance where no hard-and-fast rules exist. You simply have to experiment until you achieve an optimal balance of compression and image quality.
(Hint: Your eye is almost certainly more critical than your readers' -- be a little bit brutal.)
Unlike JPEGs, GIFs do not allow you to control compression directly. But happily, a GIF can adjust its size automatically to fit into the smallest possible space, given a specific number of colors in an image. The process of rendering an image in fewer colors is sometimes referred to as "reducing color depth" or "palette optimization."

Once the topic turns to color depth, most discussions of graphics optimization switch from English to GeekSpeak. Happily, all the technoid jargon can be distilled down to one axiom:
Fewer colors are better than more colors.

There's a lot of wasted space in most GIF images. This waste is caused by the "assumptions" that GIFs make about the number of unique colors contained in an image. By default, GIFs assume that an image has 256 unique colors. But many images (especially buttons, bullets, and the like) don't use more than a handful of unique colors. Many more images look just as good when rendered with fewer colors.

When you force a GIF to render with a smaller number of colors, the overall size of the graphic is automatically reduced.
Sort of. For reasons that are highly technoid (and really, really boring), optimization through color depth requires you to reduce the number of colors in the image to the next lowest factor of two.
So, for example, dropping a GIF from 256 colors to 129 colors won't shrink the size of the image file at all. But dropping it from 129 colors to 128 will almost always yield impressive savings in file size.

If you know why this is true, then the explanation is unnecessary. If you're not sure why it's true, then the explanation is unimportant. Just understand that size savings are achieved at 16, 32, 64, or 128 colors. (Going below 16 colors is not recommended, for reasons discussed in more detail below.)

Once you determine how to reduce color depth using your software package of choice, begin to experiment with the image. Explore options for color, dithering, etc. until you find an optimal balance of color depth and image appearance. (Note: In general, "dithered" images do not optimize as well as non-dithered images.)

Use the smallest number of colors that render the image acceptably, without compromising its quality. When you save the file in a GIF format, the image will automatically be reduced to the smallest possible size for the color palette you've selected.

Post a Comment

All Pictures - Beautiful and Sexy Pictures