Page 1 of 1

identify - force header only

Posted: 2014-05-12T13:14:49-07:00
by msundell
Is it possible to force the identify command to only read the header of an image file (if possible) instead of reading the whole file before output.
I'm interested in getting back the width/height quickly without loading image data.
Mikael

Re: identify - force header only

Posted: 2014-05-12T13:24:49-07:00
by dlemstra
Identify does not load all the image data unless you specify -verbose. What is the type of image you are trying to get the information from? Maybe the coder for that format has to read all the data before it can give you the width/height.

Re: identify - force header only

Posted: 2014-05-12T13:27:05-07:00
by fmw42

Code: Select all

identify -format "%wx%h" yourimage
see string formats at http://www.imagemagick.org/script/escape.php

Re: identify - force header only

Posted: 2014-05-12T23:20:52-07:00
by msundell
You're right as a test I did: format %[fx:w]x[fx:h] from the inch example and it forces a complete image load :-)
Using format %wx%h works as expected, perfect.
Mikael

Re: identify - force header only

Posted: 2014-05-13T19:21:50-07:00
by snibgo
If you need calculations from image dimensions, "convert" with "-ping" and "fx:" doesn't read the pixels:

Code: Select all

convert -ping g.png -format "%[fx:w/3]\n%[fx:h/3]" info: