Page 1 of 1

Identifying min-is-black Property Quickly

Posted: 2016-10-25T04:23:36-07:00
by andyleslie1968
Hello

I am currently in the process of trawling through a very large number of TIFF drawings in order to identify those drawings which are black or inverse. ie. With a photometric attribute of min-is-black.

Other than using the "identify -verbose" command which provides all the attributes for each drawing, is there a quicker and alternative method for extracting this attribute alone ?

Thanks

Andy

Re: Identifying min-is-black Property Quickly

Posted: 2016-10-25T09:07:29-07:00
by fmw42
Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images. You can upload an image to some place such as dropbox.com and put your URL here.

Or just provide the output from identify -verbose yourimage and point out the information you want to extract from it. The verbose information can be parsed to get what you want.

Alternately, try EXIFTOOL. You might be able to extract that one piece of information from it.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

For novices, see

viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/

Re: Identifying min-is-black Property Quickly

Posted: 2016-10-25T09:08:41-07:00
by tom_dl
You could use exiftool rather than Imagemagick for this. Just grep 'Photometric Interpretation' and you'll find the info. This is faster than identify -verbose by 7.7x on my PC.

Re: Identifying min-is-black Property Quickly

Posted: 2016-10-26T00:29:28-07:00
by andyleslie1968
Many Thanks Tom. I will give this a go.

Re: Identifying min-is-black Property Quickly

Posted: 2016-10-26T13:59:52-07:00
by mikmach
I love exiftool but it has one major drawback. It gets info from metadata - nothing less, nothing more.

If there is chance that metadata in images is false, eg. because some software package doesn't know it should update relevate Exif fields *ehem*, you should consider identify.

It is slower but gets real data from image.

Re: Identifying min-is-black Property Quickly

Posted: 2016-10-26T17:18:54-07:00
by fmw42
In IM, though slow, this will get it for grayscale images.

(The grep and cut in the following are unix commands, though windows may have grep?)

Code: Select all

identify -verbose DSC_0059_gray.tif | grep "tiff:photometric:" | cut -d: -f3
min-is-black

This is faster and more direct and pure Imagemagick:

Code: Select all

convert DSC_0059_gray.tif -format "%[tiff:photometric]" info:
min-is-black

Re: Identifying min-is-black Property Quickly

Posted: 2016-10-27T06:33:57-07:00
by andyleslie1968
Many Thanks.
The aforementioned convert command works a treat and has literally shaved hours off the processing time.

Re: Identifying min-is-black Property Quickly

Posted: 2016-10-31T07:24:08-07:00
by andyleslie1968
We have discovered an anomoly however.

We are currently converting and resampling all of our TIFS to a standard 200 dpi using the following command :
convert -resample 200 sample.tif sample_new.tif

We then identify the black drawings using the command before negating them:
convert sample.tif -format "%[tiff.photometric]" info:

However, it appears that the convert resample command is changing the photometric value even though the visual colour has clearly not changed.
ie. a TIF image which is clearly white visually is returning a photometric of min-is-black

Why is the resample parameter changing the photometric value ?

Is this a known issue ?

The workaround is to identify the photometric on the original TIF before resampling.

Re: Identifying min-is-black Property Quickly

Posted: 2016-10-31T09:45:07-07:00
by snibgo
The default for writing tiff is min-is-black. If you want min-is-white, set it with "-define quantum:polarity=min-is-white". See http://www.imagemagick.org/script/comma ... php#define

Re: Identifying min-is-black Property Quickly

Posted: 2016-10-31T10:07:05-07:00
by fmw42
convert -resample 200 sample.tif sample_new.tif
Proper IM syntax is to read the input raster image before any operations.