Identifying min-is-black Property Quickly

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
andyleslie1968
Posts: 4
Joined: 2016-09-27T04:55:48-07:00
Authentication code: 1151

Identifying min-is-black Property Quickly

Post by andyleslie1968 » 2016-10-25T04:23:36-07:00

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

User avatar
fmw42
Posts: 25560
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Identifying min-is-black Property Quickly

Post by fmw42 » 2016-10-25T09:07:29-07:00

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/

tom_dl
Posts: 43
Joined: 2015-02-26T08:25:44-07:00
Authentication code: 6789

Re: Identifying min-is-black Property Quickly

Post by tom_dl » 2016-10-25T09:08:41-07:00

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.

andyleslie1968
Posts: 4
Joined: 2016-09-27T04:55:48-07:00
Authentication code: 1151

Re: Identifying min-is-black Property Quickly

Post by andyleslie1968 » 2016-10-26T00:29:28-07:00

Many Thanks Tom. I will give this a go.

mikmach
Posts: 42
Joined: 2015-02-06T07:50:43-07:00
Authentication code: 6789

Re: Identifying min-is-black Property Quickly

Post by mikmach » 2016-10-26T13:59:52-07:00

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.

User avatar
fmw42
Posts: 25560
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Identifying min-is-black Property Quickly

Post by fmw42 » 2016-10-26T17:18:54-07:00

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

andyleslie1968
Posts: 4
Joined: 2016-09-27T04:55:48-07:00
Authentication code: 1151

Re: Identifying min-is-black Property Quickly

Post by andyleslie1968 » 2016-10-27T06:33:57-07:00

Many Thanks.
The aforementioned convert command works a treat and has literally shaved hours off the processing time.

andyleslie1968
Posts: 4
Joined: 2016-09-27T04:55:48-07:00
Authentication code: 1151

Re: Identifying min-is-black Property Quickly

Post by andyleslie1968 » 2016-10-31T07:24:08-07:00

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.

snibgo
Posts: 12153
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Identifying min-is-black Property Quickly

Post by snibgo » 2016-10-31T09:45:07-07:00

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
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 25560
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Identifying min-is-black Property Quickly

Post by fmw42 » 2016-10-31T10:07:05-07:00

convert -resample 200 sample.tif sample_new.tif
Proper IM syntax is to read the input raster image before any operations.

Post Reply