8bit tiff -- Change in Behavior / Bug : 8bit, 256color, PHOTOMETRIC_PALETTE == converted to 16-bit tiff
Scott Callaway <[email protected]> Wed, 19 Aug 2009 02:43:46 -0400
| Newsgroups | gmane.comp.video.image-magick.bugs |
|---|---|
| Message-ID | <[email protected]> |
I am upgrading an application that was using ImageMagick 6.3.6 use the most recent source ( ImageMagick 6.5.4-10 // ~ 8/6/2009 ).
The tests below are using Visual Studio 2008 on WinXP (32bit).
Using ImageMagick 6.3.6, the 8bit tiff image loads as a 8-bit image.
Using Imagemagick 6.5.4-10, the same 8bit tiff loads as a 16-bit image.
The translation is not a perfect scaling ( ie. The 8bit image is not multiplied by 256 ). In one example image, the source 8bit image has a max pixel of 255 (2^8). When ImageMagick 6.5.4-10 converts this image to 16bit, the max pixel is NOT 2^16 - the value is 65280 and not 65536. I believe this is happening due to round-off errors in the LUT translations.
The following programs load this image as 8bit: ImageJ, GIMP, MsPaint, etc.
Please let me know if you need an example image to reproduce this issue. I am not sending the image in this email as it is over the 100k limit. (AS_09047_050428030001_O01f00d0.TIF - 264,158 bytes )
Best regards,
Scott Callaway
######################################### Possible fix listed below
On around line 1000 of coders/tiff.c, the following changes do resolve the problem. Since I am not familiar with the internals of the imageMagick source code, I am hoping someone with more expertise can give advice.
/*
Convert TIFF image to PseudoClass MIFF image.
*/
if ((image->storage_class == PseudoClass) &&
( (photometric == PHOTOMETRIC_PALETTE)
&& (image->depth != 8)
&& (image->colors != 256) ) )
{
/* Skip this step for 8bit, 256 color, PHOTOMETRIC_PALETTE (3), tiff images. */
/* Some 8-bit monochrome tiff images are created this way. */
/* If you don't skip this code, then the 8-bit mono image will be */
/* converted to a 16-bit image with mono colormap. However, this */
/* 16-bit image will not be a strait translation from 8 to 16 bit. */
/* This approach seems reasonable since other programs */
/* like ImageJ and gimp treat these images as 8bit mono images */
/* ALSO, previous versions of ImageMagick ( ~ ver. 6.3.6 ) treated these */
/* tiff images as 8-bit tiffs as well. Seems like a bug fix is needed here. */
/* NOTE: I am not sure this is the best place to put this work-around. */
/* If this type of image had a different 'storage_class' setting */
/* like (image->storage_class != PseudoClass) [ or == DirectClass ] */
/* then this would have skipped this section as well. */
/* I am not familiar with enough with the underlaying code ... */