HALO-Photographs | VB-Script for Expression Media2 to execute ExifTool | HALO-Photographs |
VB-Script to execute ExifTool in Expression Media2 |
Expression Media2 from Microsoft offers a very convenient interface to 'Virtual Earth' from Bing for geotagging one or many images. Simply drag them into a window
with a map and drop them onto the exact location you want them to be. As simple as it can get, that's great - not new, but still great. I am convinced that all image data eventually and permanenty belongs into the image itself - and nowhere else. With this script the annotated values for Longitude and Latitude are where they belong to - inside the image(s), hence valid backup candidates. In case disaster strikes, rebuilding an image catalog becomes less a pain. For any other image formats, one must adapt the script and/or the command-line to your own gusto. One needs to know what ExifTool should do and apply changes accordingly.
So you better feel comfortable using an editor and - more important - know somewhat how to use ExifTool in the first place.
An experienced coder for Visual Basic may certainly improve the script to become more efficient, but for now I am quite happy the way it works. 'Script by Hans Loepfe, www.halo-photographs.com, May 2010 'Creative Commons License: BY-NC-SA https://creativecommons.org/licenses/by-nc-sa/2.5/ch/ 'Script expects 'Exiftool.exe' in '%root%\Windows' or in 'path'. 'Script assumes Latituderef=North and Longituderef=West 'ExifTool by Phil Harvey: http://www.sno.phy.queensu.ca/~phil/exiftool/ 'Consult the ExifTool Application Documentation: http://www.sno.phy.queensu.ca/~phil/exiftool/exiftool_pod.html 'Consult the ExifTool FAQ: http://www.sno.phy.queensu.ca/~phil/exiftool/faq.html 'By using this script, you agree to use it at your own risk. Option Explicit Const BoxTitle = "Expression Media - ExifTool" Dim ivApp, ExifApp, Exec, Cat, mediaItem, quote, PathFile, cmdline, x, y, vbl, original q = (chr(34)) 'set the quote character into a constant. This is needed for the PathFile sring x = 0 'itmes processed y = 0 'items total vbl = "-v2" 'Exiftool verboose level original = "-overwrite_original" 'use this only when you're really sure about what you're doing. Dim iptclat, iptclong If (MsgBox("For each selected media item(s), ExifTool is run according to the parameters supplied.",1, BoxTitle) = vbOk) Then Main() End If Sub Main() Set ivApp = CreateObject("ExpressionMedia.Application") Set Cat = ivApp.ActiveCatalog Set ExifApp = CreateObject("WScript.Shell") If (ivApp.Catalogs.count = 0) Then MsgBox "Please launch Expression Media.", vbCritical, kBoxTitle End If If (Cat.Selection.Count = 0) Then MsgBox "You need to select at least one media item in the active catalog in order to use this script.", vbCritical, BoxTitle Else For Each mediaItem In Cat.Selection y = y+1 if ( mediaItem.Annotations.Longitude <> "" ) then 'read Lat/Long from Image Database iptclat = mediaItem.Annotations.Latitude iptclong = mediaItem.Annotations.Longitude PathFile = quote & mediaItem.Path & quote 'a string with spaces, like a path with filename, must be quoted 'msgbox quote 'double check you've got the right 'char' that displays a ["]. 'msgbox PathFile 'view the actual path statement 'carefully examine and edit the 'cmdline' below as per your requirements to run exiftool with parameters 'use /k to leave the Window open or /c to close the window after command-execution 'exiftool -gps:GPSLongitude=<iptcLong> -gps:GPSLongituderef=W -gps:GPSLatidude=<iptcLat> -gps:GPSLatituderef=N <PathFile> <vbl> <original> cmdline = ( "%comspec% /k exiftool -gps:GPSLongitude=" & q & iptcLong & q & " -gps:GPSLatitude=" & q & iptcLat & q & " " & PathFile & " " & vbl) 'double check your command-line before shooting at live data. copy-paste and first try with test-image 'inputbox "command line",, cmdline ExifApp.Run(cmdline) 'execute ExifTool according to your entries in 'cmdline' x = x+1 'this counter may be usefull when using 'if' conditions above end if Next MsgBox "found: " & x & " / processed: " & y , vbOKOnly, "Result" End If End Sub resources:
ExifTool by Phil Harvey: https//sno.phy.queensu.ca/~phil/exiftool/ |