I have run into a problem with huge TIFF files compressed with LZW.
The example file is mainly white with black pixels. It's size is ~90MB (19046x49704). I do also have larger files and all of them compressed with LZW.
When trying to rotate the image:
Code: Select all
convert.exe "input.tif" -virtual-pixel Background -background "#000000" +distort SRT "0,0 90.2291806734696" +repage "output.tif"
Code: Select all
convert.exe image.tif -compress none out_image.tif
The file seems not to be corrupted - it is opened properly in Photoshop and IrfanView, but ImageMagick and Paint.Net do have problems with processing this file.TIFFStripSize Integer overflow
I have downloaded the sources of ImageMagick (https://www.imagemagick.org/script/install-source.php) and came into the following conclusion when working with VisualMagick:
In file: tif_strip.c there is a method in line: 220: TIFFStripSize :
Code: Select all
tmsize_t
TIFFStripSize(TIFF* tif)
{
static const char module[] = "TIFFStripSize";
uint64 m;
tmsize_t n;
m=TIFFStripSize64(tif);
n=(tmsize_t)m;
if ((uint64)n!=m)
{
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
n=0;
}
return(n);
}
Code: Select all
TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow");
Code: Select all
n=(tmsize_t)m;
The tmsize_t is defined in tiffconf.h in line 38:
Code: Select all
#define TIFF_SSIZE_T signed int
Code: Select all
#ifdef _WIN64
#define TIFF_SSIZE_T unsigned long
#else
#define TIFF_SSIZE_T signed int
#endif
By this I have allowed the system to create files that have huge strips. Unfortunatelly Windows is unable to show or create a preview thumb of the output image, and also is unable to show its properties. I believe that this is because I have probably broken a TIFF RFC, haven't I? But still the output image is 120MB in size after rotation and is shown properly in IrfanView and PhotoShop, and can also be rotated and scaled by ImageMagick.
So the question is:
Is the original file corrupted or is there a bug in ImageMagick or what?
Attached you can find a dump from exiftool with information about the StipByteCounts and StripOffsets:
http://pastebin.com/PkSWMh2Y
Regards!