Help converting tiff to 256 color indexed bmp

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
Petti
Posts: 3
Joined: 2011-05-12T16:26:46-07:00
Authentication code: 8675308

Help converting tiff to 256 color indexed bmp

Post by Petti »

I am trying to use the MagickWand API to read a tiff and output a bmp representing a 256 indexed color(PseudoClass) greyscale image of the Cyan channel. Please help, I have tried:

MagickSetImageType TrueColorType
MagickSeparateImageDepth 8
MagickSeparateImageChannel CyanChannel
MagickQuantizeImages (magick_wand, 256, CMYKColorspace, 0, 0, 0)

This is not getting me what I want, it only produces a "Colormap: 16" where as I need a 256 indexed colormap.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help converting tiff to 256 color indexed bmp

Post by fmw42 »

I don't know MagickWand API, but in command line, what you would do would be, first separate your channel, then set the depth to 8, then specify the type as either palette or grayscale, then write the output as bmp
Petti
Posts: 3
Joined: 2011-05-12T16:26:46-07:00
Authentication code: 8675308

Re: Help converting tiff to 256 color indexed bmp

Post by Petti »

Ok I tried the order that you mentioned fwm42...

MagickSeparateImageChannel (CyanChannel) - "first separate your channel"
MagickSetImageDepth (8) - "then set the depth to 8"
MagickSetImageType (PaletteType) - "then specify the type as either palette or grayscale"

This produced a colortable with only 16 colors, but I need it to produce a colortable with 256 colors. Any ideas? Is there any reason that even though I set the depth for 8 bits, it would give me less colors (16) than the full 8 bits (256)?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help converting tiff to 256 color indexed bmp

Post by fmw42 »

Petti wrote:Ok I tried the order that you mentioned fwm42...

MagickSeparateImageChannel (CyanChannel) - "first separate your channel"
MagickSetImageDepth (8) - "then set the depth to 8"
MagickSetImageType (PaletteType) - "then specify the type as either palette or grayscale"

This produced a colortable with only 16 colors, but I need it to produce a colortable with 256 colors. Any ideas? Is there any reason that even though I set the depth for 8 bits, it would give me less colors (16) than the full 8 bits (256)?

It worked fine for me in command line mode. The only thing I can say is that perhaps your input image cyan channel has fewer colors that 256.

Can you post a link to your image and I will test in command line mode?
Petti
Posts: 3
Joined: 2011-05-12T16:26:46-07:00
Authentication code: 8675308

Re: Help converting tiff to 256 color indexed bmp

Post by Petti »

Ok I looked into the image a bit more and I found that there were fewer than 256 colors in the original image, when I used a different image that I knew had 256 colors, it worked! Thanks so much for your help, I am almost complete. I have converted the C, M, and Y, but I am having trouble with Black (K). Is there something special that needs to be done for the Black Channel. The image that is produced is not Grayscale, should I use PaletteType? I need a 256 colortable Black Channel PseudoColor file.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help converting tiff to 256 color indexed bmp

Post by fmw42 »

Petti wrote:Ok I looked into the image a bit more and I found that there were fewer than 256 colors in the original image, when I used a different image that I knew had 256 colors, it worked! Thanks so much for your help, I am almost complete. I have converted the C, M, and Y, but I am having trouble with Black (K). Is there something special that needs to be done for the Black Channel. The image that is produced is not Grayscale, should I use PaletteType? I need a 256 colortable Black Channel PseudoColor file.
I do not have much experience with cmyk, but the same command should work. However, the black channel may have fewer colors that 256, so check that. You can try -type palette.

It might be best if you still have trouble to post a link to a sample image so others can see what is going on.
Post Reply