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?
Make sure you set the Reference!
The article has a working sample at the end of it.
clock1
ASKER
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.
Nick67
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.
How do I earn Piffle when I stated 20,000 images at beginning. Sorry, no go solution.
Nick67
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
clock1
ASKER
Opened mdb. Clicked process. Expected to see dimension added to picture table. What have I overlooked?
Disregard last comment from me. Realize that images are on your location and no error checking in place.
Nick67
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.
clock1
ASKER
Error checking as in MsgBox stating done appeared without error. I'm good to try again.
https://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("S
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?