2009.03.16 07:39 "Re: [Tiff] Confirming tiff integrity", by Eric Doenges
Robert,
Is there anyway to determine (via script, executable, something I need to compile, etc) if a multipage tiff contains a solid black square without viewing the actual tiff file (what I currently have to do, hundreds of times a month). I'd think that somewhere in the tiff, there might be some clue with a normal grey scale image, vs a pure solid black square on a page. What I'd really like to be able to do is write a script, or have an application that runs against a tiff and then gives a yes or no to any solid black images contained in that multipage tiff.
You could install ImageMagik (see http://www.imagemagick.org) and use the 'identify' tool with the verbose option, which will give you a histogram of the color values in the image. Here is a sample:
Image: bitrot.tif
Format: TIFF (Tagged Image File Format)
Class: DirectClass
Geometry: 576x450+0+0
Type: Bilevel
Endianess: MSB
Colorspace: Gray
Depth: 1-bit
Channel depth:
Gray: 1-bit
Channel statistics:
Gray:
Min: 0 (0)
Max: 1 (1)
Mean: 0.50088 (0.50088)
Standard deviation: 0.499999 (0.499999)
Histogram:
129828: (255,255,255) #FFFFFF white
129372: ( 0, 0, 0) #000000 black
Rendering intent: Undefined
Resolution: 1200x1200
Units: PixelsPerInch
Filesize: 31.5625kb
Interlace: None
Background color: white
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: black
Page geometry: 576x450+0+0
Dispose: Undefined
Iterations: 0
Compression: ColorBurn
Orientation: TopLeft
Signature:
fa9af6e337d8b28622ad507819e50474ce792b086b0e98d0b9182c72cbdf8045
Tiff:rows-per-strip: 450
Tainted: False
Version: ImageMagick 6.3.5 05/27/08 Q16 http://www.imagemagick.org
If the image is completely black, you should have only one entry in the histogram (if invalid images can contain some white pixels, you could calculate what percentage of the image is black by comparing the number of black pixels with the total number of pixels).
With kind regards,
Eric
--
Dr. Eric Dönges doenges@mvtec.com
MVTec Software GmbH | Neherstr. 1 | 81675 München | Germany
www.mvtec.com | Tel: +49 89 457695-0 | Fax: +49 89 457695-55
Geschäftsführer: Dr. Wolfgang Eckstein, Dr. Olaf Munkelt
Amtsgericht München HRB 114695