Convert & identify trouble

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
ch1902
Posts: 1
Joined: 2018-08-24T13:34:54-07:00
Authentication code: 1152

Convert & identify trouble

Post 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...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert & identify trouble

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert & identify trouble

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert & identify trouble

Post 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
Post Reply