Page 1 of 1

Integer Overflow on Large Tiff Image

Posted: 2013-10-24T10:21:47-07:00
by anyoneis
I have a tif which ran without errors on
ImageMagick-6.8.6-9-Q16-x64-static.exe but
ImageMagick-6.8.7-2-Q16-x86-static.exe give an error:

Thu 10/24/2013 @ 9:56:42.10 :convert "TIFF64:J100_MP_0023.tif[0]" -crop 8x8@ -scene 0 +repage -quality 100 "C:\imagemagick\extract_jpg\J100_%d.jpg"
producing type jpg
convert.exe: Integer overflow. `TIFFStripSize' @ error/tiff.c/TIFFErrors/563.
convert.exe: Cannot handle zero strip size. `TIFFReadDirectory' @ error/tiff.c/TIFFErrors/563.
convert.exe: no images defined `C:\imagemagick\extract_jpg\J100_%d.jpg' @ error/convert.c/ConvertImageCommand/3145.

Any ideas?

Re: Integer Overflow on Large Tiff Image

Posted: 2013-10-24T10:32:22-07:00
by fmw42
To help the IM developers figure it out, can you provide a link to your tiff image that is having trouble?

If not, provide the verbose information for your tiff. It sounds like the tiff may be malformed with a strip size of zero.

identify -verbose yourimage.tiff

Re: Integer Overflow on Large Tiff Image

Posted: 2013-10-24T11:07:05-07:00
by anyoneis

Re: Integer Overflow on Large Tiff Image

Posted: 2013-10-24T12:06:12-07:00
by anyoneis
I tried the latest DLL version and got this information on the image:

Image: J100_MP_0023.tif
Format: TIFF (Tagged Image File Format)
Mime type: image/tiff
Class: DirectClass
Geometry: 35712x29440+0+0
Resolution: 44038x44040
Print size: 0.810936x0.668483
Units: PixelsPerCentimeter
Type: TrueColor
Base type: TrueColor
Endianess: MSB
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Red:
min: 0 (0)
max: 255 (1)
mean: 224.483 (0.880324)
standard deviation: 27.2181 (0.106738)
kurtosis: 27.1099
skewness: -4.87031
Green:
min: 0 (0)
max: 255 (1)
mean: 216.432 (0.848753)
standard deviation: 40.5428 (0.158991)
kurtosis: 8.22477
skewness: -3.0008
Blue:
min: 0 (0)
max: 255 (1)
mean: 222.235 (0.871511)
standard deviation: 26.2422 (0.10291)
kurtosis: 22.314
skewness: -4.28371
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 221.05 (0.866863)
standard deviation: 32.0062 (0.125515)
kurtosis: 16.4096
skewness: -3.94814
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 35712x29440+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Orientation: TopLeft
Properties:
comment: x40 z0
date:create: 2013-10-24T09:54:59-07:00
date:modify: 2013-08-26T16:27:52-07:00
jpeg:sampling-factor: 1x1
signature: 14fd6ac7afb19312c15ecfd7ef1293ad69c617758fa5e5ec82958032ca093504
tiff:endian: lsb
tiff:make: Hamamatsu
tiff:model: C10730-12
tiff:photometric: YCBCR
tiff:rows-per-strip: 29440
tiff:software: NDP.scan 2.5.85
tiff:timestamp: 2013:03:20 17:20:03
Artifacts:
filename: J100_MP_0023.tif
verbose: true
Tainted: False
Filesize: 84.45MB
Number pixels: 1.0514G
Pixels per second: 6.808MB
User time: 16.833u
Elapsed time: 2:35.436
Version: ImageMagick 6.8.7-2 2013-10-18 Q16 http://www.imagemagick.org

Attempting to do the conversion resulted in:
Unhandled exception at 0x0000000077364102 (ntdll.dll) in convert.exe: 0xC0000374: A heap has been corrupted (parameters: 0x00000000773DB4B0).

David

Re: Integer Overflow on Large Tiff Image

Posted: 2013-10-24T14:19:50-07:00
by dlemstra
Libtiff checks if a certain value will fit in an int32 and for this image that won't fit. You should use the x64 version of ImageMagick and not the x86 version.

Re: Integer Overflow on Large Tiff Image

Posted: 2013-10-24T19:34:01-07:00
by snibgo
On 64-bit Windows 7, IM v6.8.7-0 Q16 64-bit, the following takes a couple of seconds:

Code: Select all

D:\web\im>%IM%convert -verbose J100_MP_9999.tif -resize 1000x1000 j2.png
J100_MP_9999.tif TIFF 35712x29440 35712x29440+0+0 8-bit TrueColor sRGB 84.45MB 0.047u 0:00.092
J100_MP_9999.tif=>j2.png TIFF 35712x29440 35712x29440+0+0 8-bit sRGB 1c 84.45MB 2.075u 0:01.073
convert.exe: No space for strip buffer. `J100_MP_9999.tif' @ error/tiff.c/TIFFErrors/563.
convert.exe: unable to extend cache `J100_MP_9999.tif': No space left on device @ error/cache.c/OpenPixelCache/3662.
The next takes 4 hours before falling over, where h:/ has 1 TB free:

Code: Select all

D:\web\im>%IM%convert -define registry:temporary-path=h:/ -verbose J100_MP_9999.tif -resize 1000x1000 j.png
J100_MP_9999.tif TIFF 35712x29440 35712x29440+0+0 8-bit TrueColor sRGB 84.45MB 22.542u 4:59.722
J100_MP_9999.tif=>j.png TIFF 35712x29440=>1000x824 1000x824+0+0 8-bit sRGB 2c 664B 551.526u 253:39.581
convert.exe: No space for strip buffer. `J100_MP_9999.tif' @ error/tiff.c/TIFFErrors/563.
It does create j3.png, but entirely black. When running, it takes 34 GB of h:/.

I'll try with the current directory "h:/", though I doubt that will help.

I don't know if I can do anything else to try and read the file.

Re: Integer Overflow on Large Tiff Image

Posted: 2013-10-25T02:41:58-07:00
by dlemstra
I just tried it with the latest beta of ImageMagick. With Q16 and x64 I am able to create multiple output images. They all have one/two colors, not sure if this is the expected result. I did have to add '-define registry:temporary-path=' because the image is ridiculously large.