[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2005-05-04
Medium Priority
Last Modified: 2008-03-06
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!

Question by:SikDave
LVL 13

Accepted Solution

softplus earned 1500 total points
ID: 13924980
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 :)
LVL 52

Expert Comment

by:Gustav Brock
ID: 13925300
You may be better off with a library (dll, no ActiveX) which can do bunches of other things as well like ImgSource:


You may not even need the registrered version ...


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question