Palettes – Color Tables

Palettes are spectrums of colors and are stored as tables.  A color palette is a single file.  Windows color tables are stored as "PAL" (Palette) files, and many programs use these PAL files for their palettes.  Photoshop came up with their own Color tables, and store them as “ACT”  (Adobe Color Table) files.

RGB files allow virtually any color – therefore, since their palette is infinite – Photoshop will show no color table for them !!!  Basically, RGB files as having no palette.  Only indexed images (GIF and 8-bit BMP) files use color palettes – and each palette is 256 colors or less.  The most common palettes are 16-color, 32-color, 216-color (Web palette) and 256 colors.

TIP:  To view a color palette (the image must be indexed mode) – in Photoshop, go to Image/Mode/Color Table.  This will simply show you the color palette that a GIF is based on - but will NOT show you the array of colors being "used" by the GIF.  

NOTE:  do not confuse Photoshop Color Palettes (act files) with color swatches (aco files).  They both contain color tables, but swatches are used for “picking” one color at a time – while a palette is a spectrum of colors that Photoshop can apply to any image. 

Integrated Palettes

Each image has it’s own integrated palette – it’s own set of colors.

Animated GIF Global and Local Palettes

In static GIF files, there is only one palette, so there is no need to distinguish it using references like "global" or "local".  .  Every color in the index requires 3 or 4 bytes of data to define it (depending on how it was originally stored). An image with a 256-color palette, may have a color index up to 1024 bytes long.

But with animated gifs - since they are comprised of multiple frames, many which differ greatly - they need more than one palette.  There, each animated GIFs has one Global Palette and numerous Local Palettes: 

Global Palette - a single palette that contains the colors used by every image (frame) of the animation

Local Palette - defines the colors in a single frame of the animation - one local palette for each frame, so there are many local palettes in an animated GIF !! The Global Palette is useful in decreasing the overall file size when the colors used by each frame are all virtually the same. When the colors vary greatly from frame to frame the Local Palette can be used to retain the overall image quality. However, it does increase the file size.

Both the Global and the Local Palettes can be controlled by defining its settings; e.g., the number of colors to use in the index; how these colors should be selected; or whether or not colors should be blended in order to make different color shades (yes, the Global and Local Palettes support "blending" between them).  

 

Palettes of Image Formats

Palettes come in many varieties, but for usability they are limited to “Indexed” color image files.  Files that contain millions of color (24-bit and 32-bit) can basically offer any color in the rainbow – so there is no need to use palettes.  I call these “palette-less” images, and JPG is the primary file type with no Palette.  Palettes are used to define a limited color set so that files can be compressed and optimized, and therefore you will use palettes when working primarily with GIF files.

Here is a short list of the most common image files – however, in today’s world, JPG and GIF represent 99% of all bitmapped image files.  BMP and TIF have fallen by the wayside.  We will not discuss vector image files here (eps, ai, wmf, png, etc.).

JPG (Joint Photographic Experts Group)  images (RGB) have no palette – well, actually they have an “infinite” palette.  They allow all RBG combinations (256x256x256) which is over 16 million colors (16,777,216).  This is 24 bit color.  To calculate how many combination you get with 24 bits, just raise 2 to the 25th power, which is 16,777,216.  That’s a huge Palette if the image used every color !!! Fortunately, JPG images have their own palettete, which consists of the colors they are actually “using” – it is a complex method and does not simply choose colors from an internal table.  Again, RGB files are “palette-less”.

GIF (Graphics Interface Format) images (indexed) allows only 256 colors (8 bits, where 29 = 256).  Now, there are many different 256 color palettes to choose from.  However, Windows, by default, has it’s own, single palette.  GIF files are popular for the web because they actually never use all 256 colors of the palette, and can be “optimized” so that the palette that is included within the file can be 8, 16, 32, 64, or 128 bits.  It can actually be of any size equalt to or below 256 !!  Ulead’s GIF animator and Photoshop’s “Image Ready” are both excellent GIF optimizers – you tell it how many colors to use, and it diffuses the existing colors (replaces them with the closes color that is available in the palette).

BMP (Bit-Mapped ?  -  no one knows what the P stands for)  files are also indexed, but they come in 2 flavors – 8-bit color and 24-but color.  The 24-bit BMP files are RGB files, and therefore are palette-less.  The 8-bit BMP files are similar to GIF files.  However, unlike GIF’s they do not offer transparency and  animation, and do not optimize down to custom palettes - so they are rarely ever used.

TIF (actually TIFF - tagged image file format) files are complex – they allow lossless OR lossy formats.  They allow LZW compression and newer TIF files support zip compression.  TIF files come in 2 flavors – IBM and Mac.  They also allow “layer” compression in either RLE or Zip (beware – few image readers can handle layered TIF’s).  In addition, TIF files can be saved using multiple resolutions – called an “image pyramid.  The entire image, layers and all, is saved multiple times,  For example, once at 72 pixels per inch, once at 144 pixels per inch, and once at 300 pixels per inch.  Again, few image viewers support image pyramid TIF’s.

TGA (TarGA) - Truevision (Targa) - bitmap file formats for storage of 24- and 32-bit truecolor images. TGA supports colomaps, alpha channel, gamma value, postage stamp image, textual information, and developer-definable data.  These are similar to bmp files, tga file are quite rare, and cannot be opened by the majority of applications.  TGA files should be converted to bmp or jpg for portability – since no one uses TGA they will not be discussed futher here,

Indexed Color Palettes

The term “indexed” applies, because each color combination is indexed by a number from 0 to 256 (for a 256-color palette).  The following example is an oversimplification, since the palette file is encoded in a non-understandable format to anything but the program using it – but functionally here is the table it represents:

 Windows 256 Color Table

Index
RGB
0
0, 0, 0
2
128,0,0
3
0,128,0
4
128,128,0
5
0,0,128
6
128,0,128
7
0,128,128
8
128,128,128
9
192,220,192
10
166,204,240
etc
etc
 ACT file (palette)

The “Browser-Safe” Palette

(browser-safe discoverer’s website:  http://www.lynda.com/hex.html )

This is a dead concept – GONE – today’s video cards and browsers now handle millions of colors  -  so no matter what palette you use – they will handle it !!!

The Browser-Safe Palette originated year ago, as the actual palette that Mosaic, Netscape, and Internet Explorer used way back when.  You see, the IBM and Mac PC’s used slightly different palettes.  They agreed on 216 colors and did not agree on 40 colors.  So the three manufacturers of the browsers got together and decided to eliminate the 40 colors that differed on the two PC platforms.  That was the birth of the 216-color palette – sometimes called the 6x6x6 color cube.

So from now on, as you optimize images and create transparent GIF’s from RGB files – ignore that option in the drop-down box that says “Web” !!!  Use Windows 256-color instead.

 

Selecting which Palette to Use

1)      for photographic images – None (use JPG)

2)      for Transparent images you will need to use a GIF and will need a palette – the best being the local adaptive palette in Photoshop.  You can also optimize simple images with only several colors (Corporate logos, etc) way down using a palette with the same several colors.  GIF Animator and Phtoshop Image Ready both work great for this.  They show you the before and after files sizes and previews of how the image will look before saving it.

If you need transparency, then create a GIF89a using the Local Adaptive palette in Photoshop.  You can also use the Windows 256-color palette, but in many cases the adaptive looks better.  Again – never use the 216-color Web palette !!

JPG vs GIF

Although many believe that GIF files are the smallest, and are the way to go with web pages - it is not true with most photographic images.

Unless you need an image to be transparent, for photographic images, there is rarely much to gain by using the GIF format.  Browsers work with both GIF and JPG, and if it is compression and small file size you’re after (i.e. fast loading web pages), highly compressed JPG’s usually look much better that GIF’s using limited-color palettes. 

Here is an example – using the original full-color 8-bit JPG (35k), an 8-bit GIF using the “color-safe” web palette (27k), and the same JPG in 24-color but highly compressed (11k).  In this case you gain compression and quality by using JPG:



Original 24-bit JPG (35k)



Image saved in 8-bit using the Browser-safe 216-color palette (27k)



24-bit JPG saved with maximum compression(11k)