Getting width/height of image without loading the whole thing...

Chris Hollman

Member
Joined
Nov 1, 2011
Messages
9
Location
Rome, New York, United States
Programming Experience
5-10
For my application I am required to get the pixel dimensions of thousands of images of various formats as quickly as possible. Right now I am loading the image into a bitmap using standard .NET code (something like Dim img as Bitmap = Bitmap.FromFile(PathString), width = img.Width, etc...). This takes far too long, which is understandable because it is loading the image to be used and displayed, which I don't need to do, I only need those two pieces of data from it.

I understand I could parse the files myself byte by byte using descriptions of the various formats to decode the data and that would probably be faster, but I don't want to write methods to do that for a dozen different image formats. My question is is there a nice happy medium between the two options where I don't have to write manual file decoding for each format but where it also does not load the entire image and takes significantly less time than what I am doing currently?

Thank you in advance.
 
Back
Top