Home > Articles

  • Print
  • + Share This

Advantages of PNG

Out of the box, .png has several advantages over .gif. Not all of these advantages are used yet to their fullest potential, and, like any new technology, some people have not yet joined the party.

Alpha Channel Transparency

The real coup is the use of an alpha channel to give the option of using 8 bits for transparency rather than .gif's single bit (a pixel on a .gif is either transparent or it's not—a pixel in a .png file can have any one of 254 levels of transparency). This means that you can do nifty things such as make an image that includes a transparent drop shadow. This is important when creating professional-looking, reusable graphics. Single-bit transparency would give a shadow that covers the original background color that the image was drawn over. Using the alpha channel means that you can create a real shadow, which is colored by whatever colors or images are underneath.

This transparency feature is far more important for the small Web graphics that typically are used on Web pages, such as colored (circular) bullets and fancy text. Alpha blending allows you to use antialiasing—creating the illusion of smooth curves on a grid of rectangular pixels by smoothly varying the pixels' colors—to make rounded and curved images that look good against any background, not just against a white background, for example. Thus, the same image can be reused in many places without the "ghosting" effect that occurs with GIFs.

Recent versions of Photoshop (5.5 and above) and Paint Shop Pro (7.0 and above) offer features that directly support the use of 8-bit transparency (such as Photoshop's Export To Web); older graphics programs had not yet embraced the format.

Gamma Correction Control

Gamma controls the brightness and saturation of an image on a monitor. Gamma "correction" refers to the ratio of the actual value of the color (the values 2, 153, and 202, for example, produce a nice shade of blue in RGB parlance) compared to the inherent brightness of the monitor. Proper gamma control ensures that the image shows up on the monitor at the proper level of brightness and proper color saturation so the image does not look washed out. Most monitors today require a gamma correction value of 2.5, but that does not necessarily mean that all computer systems should use 2.5 as the gamma correction value.

When Apple designed the Macintosh computer, it had graphic designers in mind and took gamma into consideration, giving its computers built-in system gamma correction. After the software puts the graphic image into the frame buffer, the hardware does a gamma correction of 1.4. Therefore, a PNG created on a Macintosh would use a gamma correction value of 1.8 (which is 2.5 divided by 1.4). Other systems that have built-in, or system, gamma correction are SGI and NeXT computers. PCs and popular UNIX workstations such as Sun have no "system" gamma correction and require the full 2.5 gamma correction value. Images in the PNG format contain the gamma correction value used when creating the image and, when displayed, allow the viewing system to correct the gamma and display properly on all systems.

File Size

Typically, .png files compress better than .gifs. Using a utility such as pngcrush can further reduce the size of your PNG files, but your mileage will vary. The following set of images is the same picture in a variety of saved image formats. The .png actually appears smaller than the lossy .jpg; however, the .png file is only 8-bit (as is the .gif file). At true color, which is 32 bits, the .png file is actually larger than the .jpeg file. The GIF format is incapable of saving files with more than 8 bits of color. The important point to keep in mind here is that the image fidelity in PNG images is maintained because of the lossless compression algorithms used. JPEG images lose image information each time they are saved. Additionally, the compression algorithms in JPEG have a tendency to create artifacts in the image that become annoyingly visible as the compression goes higher.

Figure 1 A 37k .jpg file, with 1% compression.

Figure 2 A 3k .jpg file, with 80% compression.

Figure 3 A 37k .gif image.

Figure 4 A 32k .png with 256 colors.


Not using the LZW algorithm for compression makes the .png format truly free. Not that you ever would have paid for your individual .gif images (and not like you won't continue to pay for a license when you buy a product like Photoshop), but you no longer have to lead the guilty life of an intellectual property thief.

Because of the lack of patent and licensing issues, PNG has become the darling format for software developers and Internet standards stalwarts who demand open standards. Because software developers do not have to negotiate a license to use LZW compression, they can charge a lower price for their software. And because open-source and free-software authors try to avoid promoting any software patents, the default image format for most free software projects is PNG.

Support for Greater Bit Depths

The PNG format supports up to 48-bit true-color or 16-bit grayscale images. GIF images can support only 256 colors (or 255 colors and transparency), and JPEG supports 24-bit color images. Using PNG can provide you with a flexible image format that scales up or down to meet your image needs.

Lossless Compression

Saving, opening, and resaving an image will not degrade its quality. Compression algorithms work by looking for redundant data in a file and replacing this with a smaller, representational "nickname." Lossy algorithms are more efficient because they don't require an exact match in redundant data—merely "close enough" is good enough. There are all sorts of techniques to reduce the visibility of throwing away perfectly good data, and they have to do mainly with human perception thresholds and rules of thumb. This works well for photographs in which areas of great similarity often exist (such as a blue expanse of sky), but not as well for images that involve text—and not at all for files whose integrity must be kept (such as text files or programs). Lossless algorithms don't compress as well, but they encode and decode all the data with exact fidelity.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.