Optimizing images in JPG format
So, graphics for Your pages is ready. But putting it on the server is too early, because it has been said more than once-if the pages swing for a long time, then there is no use from them. This article focuses on optimizing JPG images.
This format stores images with a color depth of 24bpp (TrueColor) and uses lossy compression. It does not have many ways to optimize, or rather, one: to choose the optimal compression ratio.
To implement such optimization, we need a graphics package or utility that allows us to adjust the compression ratio of the image. Unfortunately, photoshop in the basic configuration does not allow us to freely adjust the compression ratio (it offers several fixed values). However, it is possible to find modules specially connected for this operation. To optimize the graphics is better to use programs such as PhotoPaint or PaintShopPro. In these programs, it is possible to adjust the compression ratio either by setting the percentage of loss or by setting the quality value from 0 to 255.
How to determine the optimal compression ratio?
To do this, you need to save the photo at several compression ratios, and then carefully consider it. The criterion for loss of quality will be the so-called” trembling contours”, most noticeable in places of contrast transitions, and the appearance of spots in areas with smooth transitions (see figure). The compression ratio at which the distortion is not yet visible, but with an increase in its (coefficient) one step become noticeable, and will be optimal. The file size at this resolution will be minimal and without loss of quality.
If this operation is carried out with each photo, it can take too much time. But there is a way – all photos can be divided into some subtypes (for example: black-and-white photos, tinted photos, landscapes, etc.) and to each subtype to pick up the optimum coefficient. Subsequently, you can simply apply the previously found coefficient to all such photos. Below are two identical photos, but only with a different degree of compression ratio JPG. On the left is a photo recorded in PhotoShop 5.0 with a compression ratio of 3 (not optimized), and the right one is optimized with Ulead SmartSaver Pro. Note the size of the photos: they differ three times (with the same image quality).
Using progressive scan
And another small method of optimizing JPG is the use of progressive scan. This does not affect the size of the photo, but it is noticeable when loading. In the case of recording an image in a standard format, the display is displayed in horizontal bars, and we will not be able to determine its meaning until the whole image is loaded. On the contrary, when you write a file in a progressive format, the whole image appears at once, but in a rough form, and gradually improves. This gives visitors the opportunity to immediately evaluate the photo and decide whether to expect it to be docked, which will save a little time when viewing Your pages. Below, in the figures, there are two photos: the left one is recorded with a standard scan, and the right one with a progressive scan. At the time of loading pages look at how these two images are loaded, and everything will become clear to you.
Progressive JPG scanning is supported by all browsers, but not every graphics package can record in this format. Therefore, check your programs for the ability to save files with progressive scan. The latest versions of PhotoShop and PaintShopPro know how to do it.