Page 1 of 1

Convert & identify trouble

Posted: 2018-08-24T14:52:34-07:00
by ch1902
Hi, I'm trying to write a script to get the phash of generated thumbnails of files using a single command, but I'm having trouble discarding the generated thumb (which I don't need). This is the command I'm using at the moment:

Code: Select all

convert "image.jpg" -resize "128x128!" -verbose -identify -moments miff:
But it's appending the image data after all of the identify info. Is there a better command to use that'll only return image information and not the binary data as well? This is on Windows if it makes a difference...

Re: Convert & identify trouble

Posted: 2018-08-24T15:05:29-07:00
by fmw42
I am not sure what "image data" you mean. But -moments added to identify -verbose just adds the moments to the verbose information that one would get form identify -verbose. You will have to parse the text output to get just the Hu moments and PHASH values, which are 42 float values.

But you can compare two images with -metric phash and just get the comparison score. See http://www.fmwconcepts.com/misc_tests/p ... index.html

Alternately, I have some other perceptual hashes in my phashes bash unix shell script at my link below. This script can be run from Windows 10 Unix or Windows w/Cygwin. It generates a binary string for the hash, which can be stored in the image meta data or exported for use elsewhere.

Re: Convert & identify trouble

Posted: 2018-08-24T15:27:02-07:00
by snibgo
@ch1902: You are writing to an image format, "miff:", so you also get the image as well as the text. If you write to "info:" instead, you will get just the text information.

Re: Convert & identify trouble

Posted: 2018-08-24T15:45:34-07:00
by fmw42
snibgo has a good point. Now I understand your comment about "image data". Why don't you use the simpler:

Code: Select all

identify -verbose -moments image.jpg
or if you want to save to json format

Code: Select all

identify -verbose -moments image.jpg > image.json
See
https://www.imagemagick.org/script/identify.php