My Assistant
![]()
Custom Search
|
![]() ![]() |
![]() |
![]() 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. |
![]() 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. |
![]() 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 ![]() 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 |
![]() 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. |
![]() 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 ![]() Martin |
![]() 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. ![]() |
![]() 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 |
![]() 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 ![]() ![]() Martin |
![]() Post#9 | |
Posts: 1,700 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 |
![]() Post#10 | |
![]() UtterAccess Administrator Posts: 10,278 Joined: 7-December 09 From: St. Augustine, FL ![]() | 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 |
![]() Post#11 | |
Posts: 1,700 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 |
![]() Post#12 | |
![]() UtterAccess Administrator Posts: 10,278 Joined: 7-December 09 From: St. Augustine, FL ![]() | 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, |
![]() Post#13 | |
Posts: 1,700 Joined: 24-June 04 ![]() | Yes that is helpful. Thank you very much. randi |
![]()
Custom Search
|
![]() | Search Top Lo-Fi | 10th December 2019 - 11:40 AM |