support for 128-color palette GIF?

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
roach

support for 128-color palette GIF?

Post by roach »

I need to downsample an 8bit GIF file to a 7bit palette, in order to make the file smaller. I don't mean just changing the number of colors used in the image, I mean changing the size of the palette in the physical image file.

This may be a silly question, but is there any way to export (with "convert") a GIF image with a 128-color palette, rather than 256? I've tried using

Code: Select all

convert 8bit.gif -depth 7 7bit.gif
But the resulting image is actually LARGER (filesize in Kb) than the original, 8-bit image.

Is there a particular compression setting, or maybe a dithering strategy I can use that will optimize well for the LZH compression?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: support for 128-color palette GIF?

Post by fmw42 »

I am not an expert on GIF, but does GIF even support 7-bit palette?

You could look at some of the other non-IM GIF apps. See http://www.imagemagick.org/Usage/formats/#gif_non-im

Testing:

convert logo: -depth 8 logo8.gif
identify -verbose logo8.gif
Image: logo8.gif
Format: GIF (CompuServe graphics interchange format)
Class: PseudoClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: Undefined
Type: Palette
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
...
Colormap: 256
...
Filesize: 37.4KiB



convert logo: +dither -colors 128 logo7.gif
identify -verbose logo7.gif
Image: logo7.gif
Format: GIF (CompuServe graphics interchange format)
Class: PseudoClass
Geometry: 640x480+0+0
Resolution: 72x72
Print size: 8.88889x6.66667
Units: Undefined
Type: Palette
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
...
Colormap: 128
...
Filesize: 32.1KiB

So the file size is smaller with -colors 128
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: support for 128-color palette GIF?

Post by anthony »

output GIF images will automatically use a smaller palette size if the number of colors is less that that palette size.

For example 128, 64, 32, ... 2 color palettes are all handled correctly.

A verbose identify will also show the palette size being used.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply