How to get and write the dimensions of images on hard drive into an Access table

Have 20,000 images in C:\pictures that contains 10GB of images of various sizes.
Have a table that contains a field named "Location" that lists path of each image.
Have created a field in same table named "Dimension".
Want to determine the aspect ratio of each image based on width x height.
How can I get and store in same table the dimension of each image without crashing Access?
clock1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nick67Commented:
Start here
http://www.experts-exchange.com/articles/13779/More-Fun-with-Really-Large-High-Fidelity-Images-in-Access-Reports.html

It's fairly straight-forward
Set a reference to WIA
'need a reference to MS Windows Image Acquisition 2.0 library

Dim rs as recordset
Set rs = CurrentDb.Openrecordset("Select * from Location;")

Create an Image object
Dim Img As WIA.ImageFile

Dim ThePath as String
ThePath= rs!ThePath

do unitl rs.EOF
     'Set it to a filepath
      Img.LoadFile ThePath

    With rs
         .Edit
         !Dimension = Img.Height/Img.Width
         .Update
    End with
    Set Img = Nothing
    rs.movenext
Loop

Make sense?
0
clock1Author Commented:
Does rs!ThePath take the entire path listed in location?
0
Nick67Commented:
I am guessing as to what the fields in your table Location are named
Img.LoadFile requires a fully qualified path string i.e.

"c:\Somefolder\SomeSubFolder\SomeFile.jpg"

'need a reference to MS Windows Image Acquisition 2.0 library

 Dim rs as recordset
 Set rs = CurrentDb.Openrecordset("Select * from Location;")

 Create an Image object
 Dim Img As WIA.ImageFile
 Dim ThePath as String

Do Until rs.EOF
       ThePath= rs!ThePath
      'Set it to a filepath
       Img.LoadFile ThePath

     With rs
          .Edit
          !Dimension = Img.Height/Img.Width
          .Update
     End with
     Set Img = Nothing
     rs.movenext
 Loop

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

clock1Author Commented:
Yes, contains legitimate file path.  I'll give it a try.
0
Nick67Commented:
Make sure you set the Reference!
The article has a working sample at the end of it.
0
clock1Author Commented:
As I try this and read article, notice that author states cannot get 1000 images to work.  As stated in onset, I have 20,000 images.  But continuing to work.
0
Nick67Commented:
I am the author.
If you want to make 1000's PRINT on a report, well, yeah, that doesn't fly.
Processing 10's of thousands for length and width?  Piffle.
0
clock1Author Commented:
How do I earn Piffle when  I stated 20,000 images at beginning.  Sorry, no go solution.
0
Nick67Commented:
Sigh. YOU don't earn piffle.  The task at hand does :)

Getting a thousand jpgs to print on a report is VERY difficult for Access.
Getting Access to process 20K images for which you have fully qualified paths is child's-play for Access.
It'll be resource-intensive and take a bit, but eminently doable.
About 15-20 minutes or so for 20K files

Hence, piffle.

Sample attached.
This one takes 20K records from one table, finds if they exists and adds results to a second table.
Not quite what you are doing, but I am not altering production data for a sample!  You don't have my files, but the code and tables are tested and work.
piffle.mdb
0
clock1Author Commented:
Opened mdb.  Clicked process. Expected to see dimension added to picture table.  What have I overlooked?
0
clock1Author Commented:
Disregard last comment from me.  Realize that images are on your location and no error checking in place.
0
Nick67Commented:
The error checking is in place -- but since fs.FileExists(ThePath) will return false in every case on your machine, that's the branch that runs, and no records get written.
Replace the data in tblPictures with valid data of your own and you are in business.
0
clock1Author Commented:
Error checking as in MsgBox stating done appeared without error.  I'm good to try again.
0
Nick67Commented:
Going home for the weekend!
Hopefully, the code made sense to you.

Nick67
0
clock1Author Commented:
Made sense.  Thanks, points are yours!
0
clock1Author Commented:
Made sense.  Thanks, points are yours!
0
Nick67Commented:
You're welcome!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

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.