tags:

views:

48

answers:

4

Like the Title, is this possible?

I only need the width and height, so loading the image into ram would be unnecessary.

+1  A: 

Only if you read the binary format manually.

Another option, save image dimensions in the database as you put images there. They will then be available to you without the need of image loading.

Developer Art
+2  A: 

There is example code here that shows how you can read the header of images to get the width and height without loading and decoding the entire file. Obviously the approach is different for different image types though, so you may need to write your own if you are using something a little more exotic.

Martin Harris
+1  A: 

Depending on the image format you can extract the metadata with a library (e.g. EXIF for jpeg)

Maybe this SO question might help: http://stackoverflow.com/questions/42017/what-is-the-best-exif-library-for-net

MrDosu
A: 

Check this SO question: http://stackoverflow.com/questions/111345

This shows you how to extract this information from the image header without reading the entire file. Usually, the image files contain metadata at the start containing width and height in addition to other data, so that will be the quickest way of retrieving this information.

Øyvind Bråthen