Page 1 of 1

Can a gif have it's colour channel set to 4 bits

Posted: 2007-11-20T13:17:28-07:00
by Martin_Rose
Hi again,
I have now been asked if the gif's that I am creating can have a 4 bit colour channel.
When I look at the gif in photoshop all I can see is 8 and 16bit
I have run my perl script below without the $x = $image->Set(depth => '4'); and it produces a tif 163k in size with a default of 8 but I would expect if I run my script I would expect it to reduce the size of the file, but it does not. Am I expecting to much?

thanks

Martin

my $tif_to_gif = "/MartinR/graf-autoproc/$file";
my $gif_conversion = "/MartinR/gif/$file_1.gif";
my $x = $image->Read("$tif_to_gif");

$x = $image->Set(magick => 'GIF');
$x = $image->Set(depth => '4');
$x = $image->Write("$gif_conversion");
exit();

Re: Can a gif have it's colour channel set to 4 bits

Posted: 2007-11-20T17:37:24-07:00
by anthony
16bit GIF -- that is not possible. The format does not allow it.
As such photoshop is not telling you the information you thing it is telling you.

Grab "giftrans" http://www.cit.gu.edu.au/~anthony/software/#giftrans which will decode and display EXACTLY what the GIF format has defined.

IM will generate 4 bit color palette for GIF, actually it will generate 1 bit palette (two color) as well. Just reduce the number of colors in an image yourself using -color or -map and it will save it appropriately.
See http://imagemagick.org/Usage/quantization/

The color itself however is still 8 bit, just the color table and color index data is much smaller. Setting -depth for GIF is useless in this regard.