Possible bug convert 24-bit Tiff to 8-bit Tiff IM 6.8.6.7

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Possible bug convert 24-bit Tiff to 8-bit Tiff IM 6.8.6.7

Post by fmw42 »

IM 6.8.6.7 Q16 Mac OSX

Reference: viewtopic.php?f=1&t=23844&p=101359#p101359

Convert an 24-bit compressed TIFF to 8-bit compressed TIFF only works in special circumstances.

Test:

Create compressed tiff:

convert rose: -compress jpeg rose_cjpg.tiff
Type: TrueColor
Depth: 8-bit

Remove compression and convert to type palette, but result is still truecolor:

convert rose_cjpg.tiff -compress none -depth 8 -type palette rose_cjpg_cnone_palette.jpg
or reversing the order of -depth and -type
convert rose_cjpg.tiff -compress none -type palette -depth 8 rose_cjpg_cnone_palette.jpg
Type: TrueColor
Depth: 8-bit


Try writing to MIFF and then to TIFF, but result is depth 16:

convert rose_cjpg.tiff -compress none MIFF:- | convert - -depth 8 -type palette rose_cjpg_cnone_palette2.tiff
Type: Palette
Depth: 16-bit


Reverse -depth and -type, finally works.

convert rose_cjpg.tiff -compress none MIFF:- | convert - -type palette -depth 8 rose_cjpg_cnone_palette3.tiff
Type: Palette
Depth: 8-bit


Why does it not work without going to MIFF first?

Why does the order of -type -depth matter?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Possible bug convert 24-bit Tiff to 8-bit Tiff IM 6.8.6.

Post by magick »

The JPEG format or TIFF with JPEG compression does not support palette images, instead you must choose one of sRGB, CMYK, or YCbCr.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible bug convert 24-bit Tiff to 8-bit Tiff IM 6.8.6.

Post by fmw42 »

magick wrote:The JPEG format or TIFF with JPEG compression does not support palette images, instead you must choose one of sRGB, CMYK, or YCbCr.

I understand that. But I included -compress none in my command to decompress the original before writing to palette. Is that not sufficient? See my commands above.

I had to write to MIFF and pipe to TIFF output, but the -type palette had be be before -density even to get that command to work, otherwise it remained 16-bit.

Should not this work to make 8-bit palette?

convert rose_cjpg.tiff -compress none -type palette -depth 8 rose_cjpg_cnone_palette.jpg

It does not force the output to be palette, but leaves it as truecolor


But this does works to make 8bit palette! (but only if -type is before -depth otherwise it leaves it 16-bit palette)

convert rose_cjpg.tiff -compress none MIFF:- | convert - -type palette -depth 8 rose_cjpg_cnone_palette3.tiff
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Possible bug convert 24-bit Tiff to 8-bit Tiff IM 6.8.6.

Post by magick »

Should not this work to make 8-bit palette?
  • convert rose_cjpg.tiff -compress none -type palette -depth 8 rose_cjpg_cnone_palette.jpg
No because the output is JPEG and JPEG does not support colormaps. The proper command is:
  • convert rose_cjpg.tiff -type palette -depth 8 -compress none rose_cjpg_cnone_palette3.tiff
The -type palette option creates a 16-bit palette. The -depth 8 option creates an 8-bit palette. Finally, the -compress none option ensures that the TIFF image is not JPEG compressed which does not support colormapped images.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible bug convert 24-bit Tiff to 8-bit Tiff IM 6.8.6.

Post by fmw42 »

Magick wrote:convert rose_cjpg.tiff -type palette -depth 8 -compress none rose_cjpg_cnone_palette3.tiff

The -type palette option creates a 16-bit palette. The -depth 8 option creates an 8-bit palette. Finally, the -compress none option ensures that the TIFF image is not JPEG compressed which does not support colormapped images.
:oops: Very Embarrased by my mistype of the command -- accidentally typed .jpg rather than .tif for the output when testing and never noticed it.

So you are correct, it does work.

Your comment above then explains why -depth 8 must come after -type palette. (It also works if you put -compress none before -type palette.)

Thanks for the clarification.

Sorry for the false alarm!
Post Reply