identify resolution (or how many pixel image has)

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
myspacee
Posts: 153
Joined: 2007-06-14T02:09:35-07:00

identify resolution (or how many pixel image has)

Post by myspacee »

Hello from awindows user,
try to isolate image resolution value and put this information in a txt file.

I need this information to do some things, try this :

Code: Select all

identify -verbose 1.gif | find "Resolution:"
but i need only resolution value (eg: 72x72)

is there any way to obtain this in simple way, or directly how many pixel are in given image ?

thank you all for help,

m.
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: identify resolution (or how many pixel image has)

Post by GreenKoopa »

Check out the -format option. Also:
http://www.imagemagick.org/script/escape.php

Code: Select all

identify -format "%x x %y" 1.gif
convert 1.gif -format "%x x %y" info:
myspacee
Posts: 153
Joined: 2007-06-14T02:09:35-07:00

Re: identify resolution (or how many pixel image has)

Post by myspacee »

thank you for reply,
run commands and both return "72 Undefined x 72 Undefined" , why ?

any pixelcount script around ?

thank you again,

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

Re: identify resolution (or how many pixel image has)

Post by fmw42 »

myspacee wrote:thank you for reply,
run commands and both return "72 Undefined x 72 Undefined" , why ?

any pixelcount script around ?

thank you again,

m.
Either your image resolution is actually 72 and no units supplied (Undefined) or nothing is defined and IM is assuming 72.

You can see all the details that IM knows about by

identify -verbose image


To get counts of pixels, I assume you mean width x height.

convert image -format %[fx:w*h]" info:

please see all the string formats that you can get per the reply above and fx calculations that you can make such as this one at:

http://www.imagemagick.org/script/escape.php
http://www.imagemagick.org/script/fx.php
Post Reply