Page 1 of 1
covert -identify
Posted: 2008-06-23T03:08:06-07:00
by umitdogan
Hi,
I want to get the width and height of converted image. I got it with -idetify paramter but it is so hard to parse returned string.
How can format the returned string? I tried format but doest work.
Can anyone give me example?
Thank u for help.
Umit
Re: covert -identify
Posted: 2008-06-23T09:59:44-07:00
by Bonzo
If you are using php you can use getimagesize( )
What do you want to do with the result?
Re: covert -identify
Posted: 2008-06-23T10:05:41-07:00
by fmw42
convert <image> -format %w info:
convert <image> -format %h info:
or
identify -format %w <image>
identify -format %h <image>
In Unix, you can put these into variables:
width=`identify -format %w <image>`
height=`identify -format %h <image>`
see
http://www.imagemagick.org/script/escape.php
(you can also get image statistics, like the min, max, mean and standard-deviation and other information such as filename, file size, channels, colorspace, etc)
You can also do calculations:
halfwidth=`convert <image> -format "%[fx:w/2]" info:`
etc
see
http://www.imagemagick.org/Usage/transform/#fx_escapes
Re: covert -identify
Posted: 2008-06-24T18:24:27-07:00
by anthony
You can also output the size directly in a form suitable for use on HTML pages....
Code: Select all
image=logo.gif
img_size=`identify -ping -format 'WIDTH="%w" HEIGHT="%h"' "$image"`
echo "<IMG SRC=\"$image\" $img_size ALIGN=middle>"
I do this type of thing when generating 'smaller' and 'thumbnail' images of photos, as well as generating a basic HTML index file listing those images.
The
-ping option in the above causes identify to attempt to only read enough of the image file to determine simple image information such as size, without trying to read it all in. Most image format files allow you to do this, but not all. This is the advantage of "identify" over "convert"
I have updated the IM Examples Basics section on identify, which should appear in a day or so.