Reputation: 3124
I have been using OpenCV to read and manage images. But now, given the image path, I want to QUICKLY store only the image path, width and height (I do not want to load the image buffer), for a wide range of image formats.
OpenCV does not allow to do this without loading the whole image. I could implement image header parsers for a set of formats, but this might take a while.
Is there any library or so that can do this?
Upvotes: 0
Views: 738
Reputation: 207455
Yes, ImageMagick
at the command line like this:
identify -ping image.png
image.png PNG 510x500 510x500+0+0 8-bit sRGB 2.36KB 0.000u 0:00.000
Or, if you have lots of images to do in a single invocation, use it like this:
identify -ping -format "%f %w %h\n" *.png
a.png 500 500
image.png 510 500
n.png 500 510
s.png 510 500
sw.png 510 550
w.png 510 500
C/C++, Python and Perl bindings are also available. It is installed on most Linux distros, and available for OSX and Windows from here.
Upvotes: 1