Wednesday, September 4, 2013

Compression


Compression of images is something that is done in different ways (depending on the file type) to reduce the size of image files. Without compression, image files tend to be very large which can be a problem. This is especially true of images for web publishing where keeping the file sizes small improves how well, and how quickly, the pages load for the reader's web browser. Compression of images is also a consideration for customizing PDF files for posting on websites. Sizes of image and PDF files also becomes a consideration for sending as email attachments, and for posting to sites that may have limitations on file sizes for uploading online.
     Relating to images, the method used for compression depends on the file type being used for saving the image. For various reasons compression with JPG files is probably the most common type found. Images from digital cameras and images for web publishing are typically as JPG files. JPG compression also has the feature of providing a means to control and tailor how aggressively compression is used. The higher the setting for compression, the lower the quality for the saved image.


The above sample is with limited JPG compression (medium/high setting for quality). Even at the highest quality setting, you will see pixels being affected through the process of compression. Some of the dark pixels found in what should be a clear blue sky, and some of the "splotchy" looking pixels in the masonry areas of the photo, are due to compression.


This second sample is with an extreme level of compression being used (very low setting for quality). In addition to seeing dark colored pixels showing in the sky, you are now seeing a very pronounced grid of odd colorization due to the compression drastically changing the color pallet available to specific areas of the image. Though using compression to this extreme is very rarely needed, it does proved an exaggerated sense for what compression does to the quality of an images.
~~~
A note about file sizes:
     Terminology used by digital cameras may vary, though for a 1,600 x 1,200 pixel image (width x height) this is often called a 2 megapixel image. For a total, this means that 1,600 times 1,200 equals a total of 1,920,000 pixels for the image (almost 2 million pixels). Each of these pixels has an assigned color which is defined as values for red, green, and blue. With 8 bits (1 byte) being used for assigning a number for each of these values, and by multiplying this by three for each color, this would mean that at least 5,760,000 bytes of memory is needed just for recording the color values of all of the pixels. Seeing that most digital cameras, and many smart phones and other devices, capture much larger images, it becomes clear that compression can become a matter of necessity. This is not just a consideration for web publishing of images. Files sizes of these images are also an issue for the camera and its own internal memory, for transferring files from one device to another, for emailing, for posting to social sites, for storing and backing up of files to your computer or cloud, etc.
~~~
Summary:
     A note of caution with all of this - and the main point of this blog post - is the realization that though there is a need for compression there is also the need to use it carefully, and to be aware that it comes at a cost relating to its affect on image quality. Using aggressive settings for JPG compression should be reserved only for those instances where it is truly needed and for when the sacrifice of image quality can be justified.
~~~
Postscript:
     There are some instances where JPG files should not be used at all. This is especially true for curtain types of images used for print production. Generally for print, TIF files are recommended for saving of images - which has a different and less quality sacrificing method for offering file compression.
~~~

No comments:

Post a Comment