Page 1 of 1

C++ opening corrupt tif file

Posted: 2011-06-14T07:39:31-07:00
by lolhun1988
Hi,

I have a corrupt tif file that I would like to open with Magick++ and save it to the same tif format. I need to do this because I have a Scanner application that needs to set lenght parameter of the paper. If I set longer than in real it generates a corrupted tif file. (I have no clue why :() The other problem is that I can not publish these pictures but I generated one. If I use the following code and ignoring exceptions when I'm reading the file it generates a tif file that can be opened with any viewer program. If I want to perform this on a bigger tif file in this case 11124 * 7187 sizes about 22 MB can not generate the output file.

Version: ImageMagick-6.7.0-6-Q16-windows-dll.exe

Code: Select all

img.read("test_in.tif");
img.write("test_out.tif");
Unhandled exceptions:

http://dl.dropbox.com/u/5179477/ImageMagicktest/ex1.tif
http://dl.dropbox.com/u/5179477/ImageMagicktest/ex2.tif

A simulated corrupt image can be downloaded here: http://dl.dropbox.com/u/5179477/ImageMa ... t/test.tif

It's sure all exception appears because of the corrupt tif file. If I perform this operation on another pic it works fine.

The problem is that we process the images in Labview and if we have a corrupt file we can't read it. If you could help me to find a solution I would be really happy! :?

Regards,
Adam

Re: C++ opening corrupt tif file

Posted: 2011-06-23T08:59:04-07:00
by lolhun1988
I went to the press and made a corrupt tif with the scanner so I should convert this file with Magick++ somehow to use. And also the converted file must be monochrome too.

http://dl.dropbox.com/u/5179477/C%2B%2B/Scan.tif

Thanks for your help!

Re: C++ opening corrupt tif file

Posted: 2011-06-23T10:10:33-07:00
by fmw42
I don't have time now to test this, but download EXIFTOOL and try to fix the bad width value and then see if IM will handle it.

Re: C++ opening corrupt tif file

Posted: 2011-06-23T13:13:49-07:00
by fmw42
This is the error I get when convert is applied:


convert Scan.tif Scan2.tif
convert: Scan.tif: Invalid strip byte count 0, strip 11515. `TIFFFillStrip' @ error/tiff.c/TIFFErrors/496.

You should try fixing it with EXIFTOOL and see if that helps.

Looking at exiftool it appears that the stripbytecount is binary, so I am not sure how to fix that.

exiftool -s -ee -g1 -u -n -D Scan.tif
---- ExifTool ----
- ExifToolVersion : 8.24
---- System ----
- FileName : Scan.tif
- Directory : .
- FileSize : 13347366
- FileModifyDate : 2011:06:23 13:06:07-07:00
- FilePermissions : 644
---- File ----
- FileType : TIFF
- MIMEType : image/tiff
- ExifByteOrder : II
---- IFD0 ----
256 ImageWidth : 9184
257 ImageHeight : 16000
258 BitsPerSample : 1
259 Compression : 1
262 PhotometricInterpretation : 1
273 StripOffsets : (Binary data 102921 bytes, use -b option to extract)
274 Orientation : 1
277 SamplesPerPixel : 1
278 RowsPerStrip : 1
279 StripByteCounts : (Binary data 66544 bytes, use -b option to extract)
284 PlanarConfiguration : 1
---- Composite ----
- ImageSize : 9184x16000