Tuesday, October 5, 2010

What’s the Difference Between JPG, PNG, and GIF?

sshot-331 copy

As we keep building on old image technology, types of file formats keep piling up, each with their own nuances and uses. JPG, PNG, and GIF have become the most common of these because of their compatibility with modern web browsers, broadband speeds, and the needs of average users. But what sets them apart from each other?

JPG

JPG was a filetype developed by the Joint Photographic Experts Group (JPEG) to be a standard for professional photographers. Like the method ZIP files use to find redundancies in files to compress data, JPGs compress image data by reducing sections of images to blocks of pixels or “tiles.” JPG compression has the unfortunate side effect of being permanent, however, as the technology for the file was created for storing large photographic image files in surprisingly small spaces, and not for photo editing.

KeizersgrachtReguliersgrachtAmsterdam compressed

JPGs have become the de facto standard image of the internet because they can be compressed so much. A typical JPG can be compressed at a ratio of anywhere from 2:1 to as high as 50:1, depending on your settings. Particularly back in the days of dial-up internet, JPGs were the only viable way to send image information.

However, because of the lossy nature of JPG, it is not an ideal way to store art files. Even the highest quality setting for JPG is compressed, and will change the look of your image, if only slightly. JPG is also not an ideal medium for typography, crisp lines, or even photographs with sharp edges, as they are often blurred or smeared out by anti-aliasing. It is common to see these things saved as JPG, simply because the filetype is so ubiquitous.

24bitJPG

Close up of a high quality JPG.

JPGcompressed

Close up of a very lossy JPG.

The Joint Photographic Experts Group developed lossless JPG technology to combat this serious problem of quality degradation. However, because of dial-up speeds and general lack of interest in high quality non-degrading files, the JPG-LS standard never caught on.

It is possible to download plugins that allow users to open and save the lossless JPG2000, and some programs, like Apple’s Preview application, can read and save JPG2000 directly out of the box.

JPGs support 24-Bit RGB and CMYK, as well as 8-bit Grayscale. I personally do not recommend using CMYK color spaces in JPGs. It’s also important to note that Grayscale JPGs do not compress nearly as much as color ones do.

GIF

GIF, like JPG, is an older filetype, and one generally associated with the internet as opposed to photography. GIF stands for “Graphics Interchange Format” and employs the same lossless LZW compression that TIFF images use. This technology was once controversial (for patent enforcement issues) but has become an accepted format since all patents have expired.

8bit

Close up of an 8-bit color GIF.

GIF is by nature an 8-Bit color file, meaning they are limited to a palette of 256 colors, which can be picked from the RGB color model and saved to a Color Look Up Table, or CLUT. There are, however, standard color palettes, like the “Web Safe” palette.

Apart from support for transparency, GIF also is supports animations, limiting every frame to 256 preselected colors.

While GIF is not lossy like JPG, conversion to 8-Bit color distorts many images, using dither filters to optically blend, or “diffuse,” colors, similar to halftone dots or pointilism. This can radically alter an image for the worse, or, in some cases, create an interesting effect.

DANCING_BABY

GIF is not ideal for modern photography, nor image storage. At small sizes with very limited color tables, GIF images can be smaller than JPG files. But at most ordinary sizes, JPG compression will create a smaller image. They are largely out of date, useful only to create dancing babies or to sometimes create rough transparencies.

PNG

HTG HTG HTG HTG

PNG stands for Portable Network Graphics (or, depending on whom you ask, the recursive “PNG-not-GIF”). It was developed as an open alternative to GIF, which used the proprietary LZW compression algorithm discussed earlier. PNG is an excellent filetype for internet graphics, as it supports transparency in browsers with an elegance that GIF does not possess. Notice how the transparent color changes and blends with the background. Right-click the image to see. This is actually one image that is on four different background colors.

PNG supports 8-bit color like GIF, but also supports 24-bit color RGB like JPG. They are also non-lossy files, compressing photographic images without damaging image quality. PNG tends to be the biggest of the three filetypes and isn’t supported by some (usually older) browsers.

Which to use?

JPG compressed

From left to right, these files are: 24-Bit JPG Compressed, 8-Bit GIF, 8-bit PNG, Full Quality 24 Bit JPG, and 24-Bit PNG. Note that the file sizes increase in this same direction.

PNG is the largest image type for bigger images as it contains unneeded information for transparency in an extra channel. 8-Bit PNG is an option, but GIF is smaller. Neither one are good options for photography, as JPG is much smaller than lossless PNG with only minimal loss of quality. And for storage of high resolution files, JPG compresses to tiny proportions, with quality loss only visible on close inspection.

In short:

  • PNG is good option for transparency and non-lossy, smaller files. Larger files, not so much.
  • GIF is largely a novelty and only useful for animation, but can produce small 8-Bit images.
  • JPG is still the king for photographs and photo-like images on the internet.

Image of Keizersgracht, in Amsterdam by Massimo Catarinella via Wikipedia, released under Creative Commons license. Derivative images available under the same license. I don’t care to know who created the dancing baby.

Posted via email from ://allthings-bare

No comments:

Post a Comment