Page 1 of 1

identify does not work as option for convert

Posted: 2009-05-21T08:50:14-07:00
by macias
From manual it looks like identify should be a valid option for every ImageMagick program. For example convert.

convert -identify layout.jpg
convert: missing an image filename `layout.jpg' @ convert.c/ConvertImageCommand/2776.

identify as standalone program works.

IM 6.5.2-7

Re: identify does not work as option for convert

Posted: 2009-05-21T08:55:15-07:00
by magick
Try
  • convert logo: -verbose -identify null:

Re: identify does not work as option for convert

Posted: 2009-05-21T09:50:12-07:00
by macias
Ok, this one works and now I see that convert requires for identify that the filename will go first.

convert layout.jpg -identify
not
convert -identify layout.jpg

A bit odd though, I don't know if it is intended. At least error message should be more informative (imho).

Re: identify does not work as option for convert

Posted: 2009-05-21T11:07:03-07:00
by fmw42
Perhaps I misunderstand what you are trying to do. But I always just use either:

identify image

e.g.

identify rose:
rose:=>ROSE ROSE 70x46 70x46+0+0 8-bit DirectClass 9.45kb

or

convert image info:

e.g.

convert rose: info:
rose: ROSE 70x46 70x46+0+0 8-bit DirectClass 9.45kb

So, no need to add -identify to convert.


If one wants verbose information, then use either

identify -verbose image

or

convert image -verbose info:

Re: identify does not work as option for convert

Posted: 2009-05-21T11:47:19-07:00
by macias
> Perhaps I misunderstand what you are trying to do. But I always just use either:

Ok, now I know identify is a program on its own. But manual says it is an option and can be used in any program from IM set. After all, users do read manuals :)

And the error message is misleading (I would rather say, convert in such case should handle both orders of arguments, but... I won't insist).

So the real bug is error message, and the wish would be rather handling random order.

Re: identify does not work as option for convert

Posted: 2009-05-21T20:26:52-07:00
by anthony
As a FYI...

info: will save the image through the 'identify' function
-verbose flag modifies this behavour (bout also makes other operators more verbose, like -resize (filter), -segment, and -distort
-format will modify the output of info: just like in identify, allowing you to format and select the parts of the identify output you want.

But remeber info: is an OUTPUT IMAGE FILE FORMAT, output information rather than the actual image.
For example

Code: Select all

    convert rose:  -format 'size = %wx%h' info:
size = 70x46
Now your can use info: in the middle of a command by using -write
for example, get info AND write the image too

Code: Select all

    convert rose:  -format 'size = %wx%h\n' -write info:   rose.jpg
or write it to a file

Code: Select all

    convert rose:  -format 'size = %wx%h\n' -write info:size.txt   rose.jpg
If you want to pipeline the results you can (with the LATEST IM) ask IM to put the info into the error channel so it doesn't get mixed up in the image pipeline.

Code: Select all

    convert rose:  -format 'size = %wx%h\n' -write info:fd:2  JPG:- | display
now -identify is exactly equivalent to -write info: meaning you can use it and then carry on with the operations as normal.

Code: Select all

 convert rose: -format 'size = %wx%h' -identify  -scale 200%  -identify rose.jpg
size = 70x46
size = 140x92
Better still -print {format} is equivalent to -format {format} -write info: but without an extra newline added by info:, so you need to add one, if you want one.

Code: Select all

convert rose:  -print 'size = %wx%h\n'   -print 'PI = %[fx:atan(1,1)]\n'  rose.jpg 
size = 70x46
PI = 0.785398
So their you have it
  • info: write identify output controled by -format and -verbose
  • -identify or -write info: to output between image operations (to stdout).
    With -write leting you specify output files or file descriptors (output format fd:2 = Standard error)
  • -print {format} to also include a -format string to control the output of info: (to stdout)

See IM Examples
http://www.imagemagick.org/Usage/files/#info
and Identify
http://www.imagemagick.org/Usage/basics/#identify

PS Both sections should probably be re-written. Anyone like to grab the HTML, update and send me back the changes :-)