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
> Resize/Resample from code    
 
   
KingMartin
post Mar 29 2006, 08:08 AM
Post#1


Retired Moderator
Posts: 10,959
Joined: 9-October 03
From: Prague,CZ / Kiev,UA


Hello,

Owonder if there's a possibility to resize/resample a picture from VBA code.

Basically, I would need the following:

1) Browse for an jpg file (no problem with this)

2) Check its dimensions in pixels

3) Compare with given boundaries

4) Resize so that none of the dimensions has more pixels then the given limit

5) paste into Excel sheet (this, again, is no problem)

Does anybody have a hint how do I get around 2) and if possible, 4) ?

Thanks

Martin

EDIT, re 2), I found the following:
Determining JPG dimensions?
Edited by: KingMartin on Wed Mar 29 8:20:52 EST 2006.
Go to the top of the page
 
niesz
post Mar 29 2006, 08:37 AM
Post#2


Utter A-fishin'-ado
Posts: 17,958
Joined: 1-August 05
From: Cincinnati, Ohio, USA . . . ><((((°>


Are you talking about resizing a JPG, like a thumbnailer?
Here is a free utility that has a convenient command line interface (Simple Shell command) which I use to resize images for use with a website. My wife take 4MP pictures and then browses out to them and this utility renames/resizes them. All done within Access, of course.
Go to the top of the page
 
KingMartin
post Mar 29 2006, 08:45 AM
Post#3


Retired Moderator
Posts: 10,959
Joined: 9-October 03
From: Prague,CZ / Kiev,UA


Thanks, I actually don't need thumbnails but simply resampled pictures.
He exchange documents containing two-three photos and if the pictures are not resampled, the (Excel) files have easily 5 MB and more (thanks God nobody shoots with Canon Mark II N frown.gif )
So I want to automate the Excel tamplate to resize the pic automatically to a reasonable size (maybe even choose a higher jpg compression) to streamline the photo to, say, 100-200 kB...
But I think this utility is not just for thumbnails?
Martin
Go to the top of the page
 
niesz
post Mar 29 2006, 08:48 AM
Post#4


Utter A-fishin'-ado
Posts: 17,958
Joined: 1-August 05
From: Cincinnati, Ohio, USA . . . ><((((°>


I believe it has the ability to compress/resample/resize.
Go to the top of the page
 
KingMartin
post Mar 29 2006, 09:09 AM
Post#5


Retired Moderator
Posts: 10,959
Joined: 9-October 03
From: Prague,CZ / Kiev,UA


I will have a look, thanks a lot Walter
frown.gif
Martin
Go to the top of the page
 
niesz
post Mar 29 2006, 09:23 AM
Post#6


Utter A-fishin'-ado
Posts: 17,958
Joined: 1-August 05
From: Cincinnati, Ohio, USA . . . ><((((°>


No problem. I could even get you the code to do the automation but all of my source code is at home right now. sad.gif
Go to the top of the page
 
freakazeud
post Mar 30 2006, 10:26 AM
Post#7


UtterAccess VIP
Posts: 31,413
Joined: 23-September 04
From: NC, USA


Hi,
actually you can do this through the Microsoft Windows Image Acquisition (WIA). Only problem is that you or the users would need WinXP and register the WIA Automation Library version 2.0. You can find it here !
I was going to post a sample in the code archive a while back but then never had time to get to it. With WIA you can crop/resize/convert(jpg, gif, bmp...)/rotate/scale/stamp/frame images through VBA.
HTH
Good luck
Go to the top of the page
 
KingMartin
post Apr 24 2006, 03:22 AM
Post#8


Retired Moderator
Posts: 10,959
Joined: 9-October 03
From: Prague,CZ / Kiev,UA


It's never too late to say 'thanks', so
thanks.gif
frown.gif
Martin
Go to the top of the page
 
Brandi
post Mar 27 2012, 01:41 PM
Post#9



Posts: 1,573
Joined: 24-June 04



"Are you talking about resizing a JPG, like a thumbnailer?
Here is a free utility that has a convenient command line interface (Simple Shell command) which I use to resize images for use with a website. My wife take 4MP pictures and then browses out to them and this utility renames/resizes them. All done within Access, of course. "
How does this work within Access? I have an employee table with embedded photos. The photos have caused my database backend to be too large (over 2 Gig now) and so I need to reduce the size of the photos.
I have 700 records. Would I be able to use your utility and have it work on my Access table?
thank you.
Brandi
Go to the top of the page
 
jleach
post Mar 28 2012, 03:31 AM
Post#10


UtterAccess Editor
Posts: 9,811
Joined: 7-December 09
From: Staten Island, NY, USA


If it's Shell Command driven, you can use the Shell function in Access to run the required commands:
!--c1-->
CODE
Shell """C:\Some Folder\Some File.exe /someswitch /somswitch"""

Just remember to wrap your paths in double quotes as Shell would expect.
Also, note that there's other ways to store image references without storing the actual image. Keep a folder with the backend, and copy the files to the folder, renaming them to the record number. In forms and reports, you can build the path to the required picture based on the record number and use a picture control with a Linked property which would pull the images dynamically.
hth
Go to the top of the page
 
Brandi
post Mar 28 2012, 08:39 AM
Post#11



Posts: 1,573
Joined: 24-June 04



Thank you for your reply. I haven't tried anything yet and have never used the Shell command.
If I do try it, what is someswitch? I realize that is a generic name but what would the switch be for?
Thank you.
Brandi
Go to the top of the page
 
jleach
post Mar 28 2012, 08:47 AM
Post#12


UtterAccess Editor
Posts: 9,811
Joined: 7-December 09
From: Staten Island, NY, USA


A swtich is basically like an argument for performing certain actions. For example, you can use the "/p" switch when shelling Notepad in order to print the txt file instead of opening it:
!--c1-->
CODE
Shell "Notepad.exe ""C:\My Files\My Text.txt"" /p"

The way VBA would resolve that string and send it is like this:
CODE
Notepad.exe "C:\My Files\My Text.txt" /p

This is the same command you would use if you were to open the cmd prompt (the old DOS shell looking thing) and type it there.
For most programs that have a cmdline interface, you can type the name of the command followed by " /?" to see a list of all the available switches:
CODE
Notepad.exe /?

For something like the example that Walter provided, you'd probably be better off checking their documentation to see what switches are available though. Likely they're all layed out there, and it shouldn't be too difficult to out which commands and switches to shell in order to do what you need.
Generally the most difficult part of shelling commands with Access is making sure the command string is wrapped with quotes as required (any path with a space in it needs to be wrapped in a set of double quotes when it shells, so we have to do the quote manipulation thing from VBA to make it work).
A good way to troubleshoot that is to put the command string into a variable in vba, and use Debug.Print to check how the string resolves before passing it into the Shell function. Once you have the string built correctly, it's just a simple matter of Shell MyString:
CODE
Dim MyString As String
MyString = "Notepad.exe """ & Me.ThisTextFile & """ /p"
Debug.Print MyString
Shell MyString

Hope that helps,
Go to the top of the page
 
Brandi
post Mar 28 2012, 09:36 AM
Post#13



Posts: 1,573
Joined: 24-June 04



Yes that is helpful. Thank you very much.
randi
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    16th December 2017 - 02:04 AM