inside the OuTpaTienT mind...

by OuTpaTienT

     File size versus image quality. The age old (computer age) trade off when dealing with image files. To reduce the file size you simply have to lose some of the image quality. There really is no way around this fact. But there are means within this limitation that we can work with. And one of them is called "weighted optimization".

     What it means is you can reduce the image quality while influencing specific portions of the image to be more or less affected by that quality reduction.

     Two commonly used methods of reducing file size are to convert to a GIF (which uses a reduced color palette of 256 colors or less) or convert to a JPG (which uses a form of lossy compression as well as color reduction of it's palette). When saving to either one of these formats from Adobe Photoshop it's possible to influence the quality reduction involved and have it weigh more heavily on some parts of the image and less so on other parts. This "weighted optimization" can be handy in things like banners or other images that involve text because it is vital to keep that text readable, or it can be used in any image where you'd like to keep a specific portion of the image looking as good as possible.

     To use this feature of Photoshop you must first define a mask and save it. You want the mask to consist of the area of your image that you are least concerned about quality. So in essence just select the important parts of the image that you'd like to be least affected by quality reduction, then choose "selection", "inverse", then "save selection".

     For example, let's say I wanted to convert the following image to a GIF file (with a reduced color palette) yet I wanted the border around the yellow area (that raised 3D looking black/blue border) to remain looking as good as possible. Maybe in the big picture that blue/black border is part of some larger text or logo.

     We would first select all the surrounding area of our blue/black border then save the selection as an alpha channel. After making your selection, just go to menu and choose "Select" and "Save selection".

     Now go to the menu again and choose "File" then "Save for web" set the options to save the image as a 256 color GIF file. Now go to this area of the options and click on it:



     And choose the channel that is the mask you previously saved. After saying "ok" to that you should notice the 256 color palette change to favor the portion of your image you want to keep looking good. In this case the palette now contains much more blue and dark colors which will help the blue/black border retain more image quality than normal.

     Here's what a close up of the image looks like as a 256 and 128 color GIF. Normal color reduction is on the left side and weighted color reduction is on the right. Remember we are mostly concerned with keeping that blue/black border looking good and we are less concerned with the rest of the image.

     Notice how in both cases the weighted optimization keeps the blue/black border looking better than it would otherwise.

     This same procedure can be applied to JPG image compression. Using the same mask (alpha channel) we can make the loss of image quality normally seen with JPG compression not affect our chosen areas as much as normal.

     Notice how with the JPG, the color banding within the blue/black area doesn't really need much improvement but look how under normal circumstances the blue color very noticeably bleeds out onto the yellow. This is prevented with our weighted optimization.

     The same process may also be used with the GIF "lossy" setting and "dither" setting, shown here.

     Although often we might want the overall image quality to remain constant, weighted optimization can come in handy for certain projects where you may want specific portions of the image to not degrade in quality as you try to shrink the file size.

Don Cowger / OIC
OuTpaTienT Imaging Consulting (OIC) for logos, banners, and virtually any imaging service you need.