Love the web

Love the web is a design, programming, and usability blog

Influence the Colour Range in 8-bit Graphics 3 comments

Reg Sime 18 Mar 2010

Update! This article was written for Photoshop CS3. It would appear CS5 does not offer the same functionality.

This is a neat little technique I stumbled upon one day while poking around in Photoshop's “Save for Web…” settings. It allows weighting of Photoshop's colour palette when saving 8-bit images. As with a lot of discoveries in life, it wasn't long before I found it coming in very handy.

The problem

One of our designers gave me this header graphic for the Fringe Festival website.

original graphic

Saving this graphic for web as an 8-bit image was creating a lot of undesirable banding in the gradients of the coloured twirls. (Saving as a 24-bit image was out of the question given the file size. Saving as .jpg could be a consideration, but as we shall see, not necessary.)

Banding issue

The PNG and GIF compression algorithms determine their palettes based on frequency of each colour. So in this case the blacks and greys are over represented, while the pinks and blues (and to some extent yellows) are under represented. That's why the banding is most obvious in the colourful sections of the graphic.

Colour palette before

If we could reduce the number of greys (henceforth referred to as 'background') in the palette we would free up spots for the bright colours ('foreground') and thereby achieve cleaner looking gradients. Well, thanks to Photoshop's 'Use a channel to influence color reduction' option we can do just that.

The solution

The first thing we need to do is create an Alpha channel to define our foreground / background separation. This is easily achieved using Photoshop's 'Colour Range…' tool (Select > Colour Range…). By SHIFT-clicking on a few background areas in the graphic and sliding the 'Fuzziness' setting to '200' I was able to quickly isolate the background. Then check the 'Invert' checkbox to select the foreground.

Click 'OK', then select the 'Channels' palette (Window > Channels). Create a new channel (icon at bottom of palette) and fill your selection with white.

Now we're ready to compress the graphic. Go to the Save for Web interface (File > Save for Web & Devices…). Select PNG-8 or GIF, then click on the 'Use a channel to influence color reduction' icon

In the dialog that pops up select your Channel from the dropdown ('Alpha 1' in our case). Also note you could use the same technique with text or vector shape layers.

Click OK and you're done. Note the new & improved colour palette sporting a large reduction in the number of dark greys.

Colour palette after

Employing this method I was not only able to enhance the appearance of the graphic but in this case shaved almost 30% off the file size.

Read the next post - fadeSlide.js - a jQuery slider

Subscribe to these comments

3 comments submit a comment

23 Mar 2010

Mark Shingleton

That is a nice technique. :)

I've been using Fireworks mostly but I don't think it has that 'Use a channel to influence color reduction' feature. Will have to check it out.

13 Apr 2011

Castle

Thank you for posting this. I have been fiddling with Fireworks myself, like Mark said above. I am a kind of DIY person, which is no different when it comes to web design (http://designsbyjacq.com). I will need to pay attention to basic techniques so I can get up to this level! Thanks again.

28 Jul 2011

Mike Vanderpool

Great technique....definitely need to check this out. Thanx for the article. Virginia web design in the Metropolitan DC area, Vision Studios Design. Check us out @ http://www.visionstudiosdesign.com.

Submit a comment

Submit comment