PNG File Quality

Facebooktwitterlinkedin

Today’s Question: I often use PNG files in compositing images, because they allow for transparent pixels. Are they like JPEGs in that every time you open, modify, then save the file, you lose image quality?

Tim’s Quick Answer: No, PNG (Portable Network Graphics) images do not have the same quality loss that can be a factor with JPEG images, because the PNG format supports lossless image compression to reduce file size. When you save a normal JPEG image, the compression applied always results in some loss of quality due to the type of compression used.

More Detail: The compression used for JPEG images is “lossy” compression, meaning some information is lost in the process of reducing the file size for a JPEG image. JPEG compression operates by simplifying the information within pixel grids (generally 16 by 16 pixels to a block). That compression causes a change in some pixel values, and can also result in artifacts such as a slight grid texture reflecting the grid used for compression.

Because the compression for a JPEG image is re-applied every time the file is saved, if there have been changes to the pixel values for the image it is possible to have a cumulative degradation effect for JPEG images that are repeatedly altered and saved. Simply opening a JPEG and re-saving it will not cause any further degradation, because the same algorithm would be applied to the same image data, resulting in the same result for the JPEG file.

The PNG file format employs lossless compression, so re-saving the image multiple times (even with changes) will not cause a further degradation of image quality.

I should hasten to add that while PNG images do include support for transparency, they don’t offer the flexibility of an image layer with a layer mask in Photoshop. The transparency of PNG images can most certainly be convenient when assembling images into a composite. However, if you have erased pixels to create that transparency, you can never get those pixels back in the PNG image.

Instead, I prefer to employ a layer mask in the original image, saving that result as a TIFF (Tagged Image File Format) image so that the layer mask is preserved. This approach enables you to employ the effect of transparency for a composite image, while still maintaining the ability to go back and alter which portions of the source image are actually visible versus hidden.