Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Purpose of color resolution bits in a gif

Tags:

image

I've dissected a gif image and here is the data in the header: ['G', 'I', 'F', '8', '9', 'a', '^', '\x01', '^', '\x01', '\x87', '\x00', '\x00', '\x00', '\x00', '\x00', '\x01', '\x00', '\x00', '\x01']

The 0x87 represents the flag byte in the gif. Converting this to binary results in 0b10000111.

I'm using http://www.matthewflickinger.com/lab/whatsinagif/bits_and_bytes.asp as a reference.

So, according that to that website, the gif has a (zero + 1) colour resolution (2 possible colours, even though the image has many more). I tried editing this number and it didn't seem to change anything. Can someone explain the purpose of the colour resolution bits?

like image 654
malex Avatar asked Aug 19 '11 22:08

malex


People also ask

How many colors can GIF support?

About the GIF format GIF is supported by most browsers. The GIF format uses LZW compression, which is a lossless compression method. However, because GIF files are limited to 256 colors, optimizing an original 24‑bit image as an 8‑bit GIF can subtract colors from an image.

What is bit color depth?

The colour depth of an image is measured in bits . The number of bits indicates how many colours are available for each pixel. In the black and white image, only two colours are needed. This means it has a colour depth of 1 bit.

How does color depth work?

Color depth, also called bit depth, refers to the number of colors each pixel in an image can display. As the color depth increases, the number of colors an image can display increases. Each pixel's color information is stored in a certain number of computer bits — from 1 bit to 48 bits.

How many colors are in an 8 bit image?

The number, 256, is 2 raised to the 8th power or the 8-bit color depth. This means that each of the RGB channels has 256 shades so there are 256x256x256 or 16,777,216 colors in total in this 8-bit RGB system. An 8-bit color system is capable of producing over 16 million colors.


1 Answers

you can edit it without harm because it's not needed to decode the data - all it does is describe the "source" of the data (the last three bits in that byte are what apply to this particular image).

the standard itself http://www.w3.org/Graphics/GIF/spec-gif89a.txt (page 9) says:

This value represents the size of the entire palette from which the colors in the graphic were selected, not the number of colors actually used in the graphic.

and then goes on to add:

This value should be set to indicate the richness of the original palette, even if not every color from the whole palette is available on the source machine.

so it looks like even the original authors didn't have much idea for how it would be used. and since it's not really useful, i imagine it's not set correctly by some software.

[the only use i can see is that if this value were larger than the actual colour depth used you could add a caption/popup saying "the original image was better than this".]

like image 151
andrew cooke Avatar answered Oct 01 '22 02:10

andrew cooke