identify does not work as option for convert

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
macias
Posts: 28
Joined: 2008-12-10T13:44:19-07:00

identify does not work as option for convert

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: identify does not work as option for convert

Post by magick »

Try
  • convert logo: -verbose -identify null:
macias
Posts: 28
Joined: 2008-12-10T13:44:19-07:00

Re: identify does not work as option for convert

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

Re: identify does not work as option for convert

Post 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:
macias
Posts: 28
Joined: 2008-12-10T13:44:19-07:00

Re: identify does not work as option for convert

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: identify does not work as option for convert

Post 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 :-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply