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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Martin_Rose

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

Post 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();
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply