command line - get image infos for database

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
zoro17
Posts: 5
Joined: 2012-03-24T06:12:29-07:00
Authentication code: 8675308

command line - get image infos for database

Post by zoro17 »

Hi all,
I am newbie in ImageMagick. Therefor this question (?):
I want to get all information of a any image (png, jpg, tiff) using the command line.
My ambition is to store this image information in a database.

I know that the compare functions has many parameters, but I don't want to compare the relevant image with another one.
(Maybe I could use a black or white image as a reference to compare?)
Is there a function with parameters to get deep infos of image like the compare function?
Or is it possible to store the compare results in a text file and not in a result image?
If there is a function which are the important parameters to analyze a image when the imagesize is no object?
I know that I have to test my development plan, but I want to start...

Please, give me some advice.

Kind regards
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: command line - get image infos for database

Post by Bonzo »

Yes you can get a lot of information using:

Code: Select all

identify -verbose image
See: http://www.rubblewebs.co.uk/imagemagick ... /image.php
I also belive you can save the information to a text file.
You may be able to select certain information using FX.

I think you need to say how you are going to be using your code as there are lots of ways to do things.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: command line - get image infos for database

Post by fmw42 »

As Bonzo said, you can get all the information about an image that is available from

identify -verbose yourimage

You can write that to a file via:

identify -verbose yourimage > rose.txt

or if on unix, to a string variable

text=`identify -verbose yourimage`

Then you will have to use somethings like grep and sed, etc to parse the data you want to extract and put into your database.

If there are only certain things you want, you may be able to extract them one at a time, using string formats. See http://www.imagemagick.org/script/escape.php

For example, you can get the width of the image by

width=`convert yourimage -format "%w" info:`




I am not sure why you need compare. If all you want to know is where is the min, max, mean, standard deviations, etc, then that is available globally and by channel from the verbose information. There is also a histogram available as well as information about the filesize, resolution, colorspace, etc in the verbose information.

If this is not what you need, then please clarify further. An example image and what you need from it would be useful for us to know more about your problem.
zoro17
Posts: 5
Joined: 2012-03-24T06:12:29-07:00
Authentication code: 8675308

Re: command line - get image infos for database

Post by zoro17 »

Hallo Bonzo, hallo fmw42,

thank you for your information! This sounds very good...

My consideration is to upload an image via php, start the command line on the webserver,
(maybe resize it) and store the image information in a database.
Later on I want to upload a similar (not exactly the same image) image.
I try to find images in the database which looks similar to the last image.
For this I want to use threshold values to find the relevant images.
The interesting thing to find only 1 images (like image recognition).
Therefore I have to test which parameters of the image is the important info
to find this images.
A lot of testing I think...

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

Re: command line - get image infos for database

Post by fmw42 »

zoro17
Posts: 5
Joined: 2012-03-24T06:12:29-07:00
Authentication code: 8675308

Re: command line - get image infos for database

Post by zoro17 »

Thank you for the links. Good stuff to read!

Of course 3 values will be enough to distinguish.
Therefore I am searching for the relevant parameters to do this.
I will try to find the these testing with different images.
If ImageMagick is fast enough I will collect all infos about the image.
Maybe ImageMagick is the right tool to get these infos.

It will be a lot of work but I try :-)

If you have more links about this topic please send me.

Kind regards.
zoro17
Posts: 5
Joined: 2012-03-24T06:12:29-07:00
Authentication code: 8675308

Re: command line - get image infos for database

Post by zoro17 »

I think "fingerprint" of an image is the key word for my intention.
viewtopic.php?f=1&t=8968&start=0

anthony wrote some interesting aspects about this topic.

Are there any new insights about creating fingerprints with ImageMagick?

Kind regards.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: command line - get image infos for database

Post by anthony »

Note since I did that stuff whcih was some years ago.

The fingerprint (an array of 9 colors) I found useful for finiding similar matches, before going in deeper compares for 'nearer' matches, which I then presented to the user (me) for verification and handling.

That array was typically good enough to divide images into major groups, including 'two-color gradients' (eg black and white but not nessary using those colors) landscape, seascape, faces, etc.

I am however keen on hearing other peoples findings, though few ever report back.


There was a paper I saw that used a search heiestic on a similar array of value though they limit it to simply 'dark, midtone, light' in each area, as a simplification.
http://citeseerx.ist.psu.edu/viewdoc/su ... .1.80.3503

Note I have not been activally searching research papers which I often find hard to understand (an I am a university honors graduate!)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
zoro17
Posts: 5
Joined: 2012-03-24T06:12:29-07:00
Authentication code: 8675308

Re: command line - get image infos for database

Post by zoro17 »

Hi anthony,

thank you for your info!
The last days I read about image recognition. My impression is that the SURF
algorithm could be a solution for that recognition. To analyse the image via
imagemagick could be not enough if I want to be independent of rotation
and different lighting of the image.

And the means a lot of work...

Kind regards
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: command line - get image infos for database

Post by anthony »

Regardless of if your solution is ImageMagick or not. Please let us know what you find out :-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply