identify - force header only

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
msundell
Posts: 13
Joined: 2013-12-17T00:53:52-07:00
Authentication code: 6789

identify - force header only

Post 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
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: identify - force header only

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: identify - force header only

Post by fmw42 »

Code: Select all

identify -format "%wx%h" yourimage
see string formats at http://www.imagemagick.org/script/escape.php
msundell
Posts: 13
Joined: 2013-12-17T00:53:52-07:00
Authentication code: 6789

Re: identify - force header only

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: identify - force header only

Post 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:
snibgo's IM pages: im.snibgo.com
Post Reply