newbie problem extracting jpg preview from DNG files with VBA in MS-Access

Started by marcb, September 19, 2015, 09:23:49 AM

Previous topic - Next topic

marcb

Hi,

I'm stuck trying to display the embedded jpeg previews of DNG files in a picturebox on a MS-Access form.

I found this code which seems to do exactly what I need:

Private Sub GetImage(ByVal FileName As String, ByRef picturebox As PictureBox)
Dim ExifTool As New Process

ExifTool.StartInfo.FileName = "C:\Programme\ExifTool\exiftool.exe"
ExifTool.StartInfo.Arguments = "-b -previewimage" + " " + Chr(34) + FileName + Chr(34)
ExifTool.StartInfo.UseShellExecute = False
ExifTool.StartInfo.RedirectStandardOutput = True
ExifTool.StartInfo.CreateNoWindow = True
ExifTool.Start()
picturebox.Image = New Bitmap(ExifTool.StandardOutput.BaseStream).GetThumbnailImage(120, 80, Nothing, Nothing)
ExifTool.Close()
End Sub


But it is in .NET while I'm working in VBA where "Process", "Bitmap" and "Picturebox.Image" dont seem to be defined.
I'm not a programmer and so I dont understand most of the code examples I find on the net, or I cant figure out which libraries to reference to make it work.
And so I'm stuck of this simple problem, I have no idea how to make this work in VBA/MS-Access.

Anyone an idea?
tnx
marc

Skippy

@ marc
You might want to include the URL where you found this code as the code shown above is probably part of a larger project.  I only up to 10% with dot net, but the exiftool.something in the code is likely to be a class that is defined somewhere else in the code.  It would be part of a wrapper and not part of exiftool itself. 

Ms-access has enough power to quickly display from one to approximately 4 full size jpeg images in picture boxes.  My images are 12 mega pixel images of about 5 MB size.  Thumbs can help improve application performance but they might not be essential.  In my ms-access applications, I search for a /thumbs directory that is a subdirectory for each photo folder.  I create and stock the /thumbs directory manually when I import the photos but could write a procedure to do this automatically.  The hitch for me is finding a good jpeg resampler that can be called from ms-access.  If a thumbs directory is not found or the required thumbnail is not found, then I display the original.  I test for file existence before attempting to display the original and remove the last picture from the picture control if the required photo is not found.  A lot of cameras created jpg images as well as raw images and perhaps you could use the jpg images for display until you find a raw only solution.  So you would find the path to the .dng image, then search for the associated jpg and if found, load this into the image control.

Ms-access is a database and it has a fine set of tools for looking after data stored in internal tables.  It does not have built in tools for reading external files and processing their contents or good tools for running external processes.  It does however have a general purpose language that can be used to make some of the tools needed for doing these tasks.  Making the tools takes time.  Checking for thumbnails is about 30 lines of code, checking for file existence is about 10 lines.  In my case, I have built a full set of these functions and it adds up to something like 10 000 lines of code.  In contrast, dot net already has all of these functions and two lines of code in dot net is the same as twenty lines of code in ms-access.  It is a shame that dot net is a real pig for beginners.  To get moving faster, I have contracted an Indian developer via Upwork (oDesk) to write some small test applications for me that I can pull apart to see how they work.  A few of these projects include harvesting info from a directory full of photos and putting the data into ms-access tables.  I generally get the code in a zip file within two weeks and compile it myself.  Apparently there is a dot net wrapper for exiftool.  It might be possible to built the function that you want as a small dot net application that can be called (shelled to) from ms-access.  I would think that the cost would be somewhere from $50 to $100 in $USD.  However adding features after that would be easier as all the setup would have been done.  The developers name is Sunil Sharma (there are dozens of Indian developers with the same name) and his upwork page is https://www.upwork.com/freelancers/~01269b3e4c7cac002b.  All the projects listed are mine and they are all photography related.  If you want to try this route, I would be happy to provide the VBA code for interacting with the dot net application (in exchange for being able to use the dot net code in my applications).

Skippy.