UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Dynamic Image Sizing - Get Size From Attachment Properties?, Access 2016    
 
   
B99
post May 20 2020, 12:19 PM
Post#1



Posts: 62
Joined: 15-April 20



Hi All,

Is there a way to get the size of an image that is stored as an attachment? I have a report that may have 0:M images attached to the detail records and I'd like to dynamically size the image control based on the size of the attached image. I found a way to do this if the file is external by getting the height and width properties (in pixels), then checking the user's screen resolution to determine DPI, then converting pixels to twips and setting the control properties. But I'm curious if there is a way to get the height and width properties of an attachment.

Or maybe get the dimensions when the attachment is saved and store them in a table? Is there a different preferred method to do this?
Go to the top of the page
 
theDBguy
post May 20 2020, 01:01 PM
Post#2


UA Moderator
Posts: 78,476
Joined: 19-June 07
From: SunnySandyEggo


Hi. I also think it would be easier if the image size is permanently stored with the data; but otherwise, you could also extract the attachment into an external file during the report process and go from there.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
B99
post May 20 2020, 02:30 PM
Post#3



Posts: 62
Joined: 15-April 20



OK, just wanted to be sure I didn't overlook an obvious property. Thanks!
Go to the top of the page
 
theDBguy
post May 20 2020, 02:35 PM
Post#4


UA Moderator
Posts: 78,476
Joined: 19-June 07
From: SunnySandyEggo


Sadly, I am not aware of any property for image size. Good luck!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
jleach
post May 21 2020, 06:24 AM
Post#5


UtterAccess Administrator
Posts: 10,573
Joined: 7-December 09
From: St. Augustine, FL


If you can get it into a file you can use some shell scripting to get extended properties of the file and grab the dimensions from there. Let me know if you need the code, I'll dig it up from somewhere.

--------------------
Jack D. Leach
Founder & CEO
Dymeng Services Inc.
Business Software Solutions
Go to the top of the page
 
B99
post May 21 2020, 10:10 AM
Post#6



Posts: 62
Joined: 15-April 20



Hi Jack, I think I'm going to go the file route. I found some code that creates an ImageFile object, then loads it with the image which apparently provides access to the width and height file properties. I'm assuming that those properties are always set when an image is created/saved. So far it has worked in my testing. (The code is in an example DB I uploaded in my post about resizing the detail section.)

My current thought is to have an image directory that will store the images and create a new image table that will store the path, file name and other attributes. Then the user picks an image file from the table and I link the image record to the detail data record via a join table.

I see a few benefits with this in that 1) it will keep the DB smaller; 2) it allows me to access the image dimensions; 3) the image reference record is created once and available to link to multiple records in the data set, rather than attaching the same image to multiple records.

Hopefully I'm not overlooking any downsides!
Go to the top of the page
 
jleach
post May 21 2020, 10:44 AM
Post#7


UtterAccess Administrator
Posts: 10,573
Joined: 7-December 09
From: St. Augustine, FL


That sounds like the generally preferred approach to me, I usually go with directory storage like that as well.

--------------------
Jack D. Leach
Founder & CEO
Dymeng Services Inc.
Business Software Solutions
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    9th July 2020 - 12:56 PM