VBA - Image Dimensions (Width and Hieght) in Pixels, without loading into a control

Hi There.

I have an Image Batching application that I am writting in Access2000 (will upgrade to 2003 soon) on XP Sp1. It handles sometimes over 800 images at a time that vary from 5mb to 114mb+ in size.

For each selected file (that is stored on a CD/Removable Media/Any Drive), I need a VBA function to retrieve, and store in an existing table, the following info:

* Filename with extension - not the full path.
* Image Width in Pixels
* Image Height in Pixels

As the files are so huge, and many, I don't want to load them into a control on a form, but reference them directly from their current path. And I need to do it very quickly.

The stdOle and Access image objects cannot handle .tif files, otherwise I would be out of the woods. (ie: IPictureDisp )

I was looking at GDI+ API calls to retreive the info, but this is beyond my programming scope. I don't want to rely on purchasing ActiveX controls to handle it.

This API Function: GetBitmapDimensionEx doesn't work, because 'the retrieved dimensions must have been set by the SetBitmapDimensionEx function' (MSDN).

Windows Explorer accesses the dimensions of the bitmaps (Tiff's and Jpeg's) perfectly and super quick, and is displayed by choosing View>Details, then View>Choose Details and 'Checking' the Dimensions box. That information is all I need, but I need it in an MS Access table.

Simple Question, difficult answer.

Please Help!



SikDaveAsked:
Who is Participating?
 
softplusCommented:
Hi SikDave,
For jpg, bmp, png and gifs, you can use something like this: http://www.4guysfromrolla.com/webtech/050300-1.shtml (look at the code for imgsz.asp on the bottom) - it reads the dimensions directly out of the image file without having to load it into any control.
For tiffs, you could extend the code using this as a guide: http://www.ee.cooper.edu/courses/course_pages/past_courses/EE458/TIFF/ , check the tags 7 and 8 (ImageLength and ImageWidth).
Using a system like that, you can read the size directly without having to load / parse the whole image into memory. It's quite a bit faster, but requires a larger chunk of code (and testing). Another possibility would be a component like "Full Image Info": http://www.graphicregion.com/imageinfo.htm
Hope this helps :)
John
0
 
Gustav BrockCIOCommented:
You may be better off with a library (dll, no ActiveX) which can do bunches of other things as well like ImgSource:

http://www.smalleranimals.com/isource/isfeatures.htm

You may not even need the registrered version ...

/gustav
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.