Page 1 of 1

command line - get image infos for database

Posted: 2012-03-24T08:21:37-07:00
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

Re: command line - get image infos for database

Posted: 2012-03-24T08:56:37-07:00
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.

Re: command line - get image infos for database

Posted: 2012-03-24T09:49:27-07:00
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.

Re: command line - get image infos for database

Posted: 2012-03-24T14:12:23-07:00
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

Re: command line - get image infos for database

Posted: 2012-03-24T15:32:25-07:00
by fmw42

Re: command line - get image infos for database

Posted: 2012-03-24T15:48:54-07:00
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.

Re: command line - get image infos for database

Posted: 2012-03-25T06:29:30-07:00
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.

Re: command line - get image infos for database

Posted: 2012-03-25T19:24:05-07:00
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!)

Re: command line - get image infos for database

Posted: 2012-04-01T03:18:21-07:00
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

Re: command line - get image infos for database

Posted: 2012-04-01T06:17:45-07:00
by anthony
Regardless of if your solution is ImageMagick or not. Please let us know what you find out :-)