# Lightroom to Gallery Plugin: Export images with Original Path in Metadata



## Jonathon Batson (Feb 27, 2008)

Thread moved from http://www.lightroomqueen.com/community/showthread.php?t=114' 
*Problem:* From a large removable HDD with 6' '''+ images, create selections of these images in Lightroom (total approx 1''') and export these selections in a lower res into individual albums in Gallery. From Gallery users will have the ability to see where to access the "original" image in max resolution via viewing a Metadata field where the path to the original image has been stored. (*not* the temp image location that lightroom creates). 
*Solution so far:* Using Lightroom to Gallery plugin https://sourceforge.net/projects/lr-to-gallery/ , and combined with the exiftool, and a little Lua hacking, I can execute a system command at the time of the export for each individual exporting image. The result is a metadata field with the path to the image. For example: 
	
	



```
exiftool -UserComment='/var/tmp/folders.29234/TemporaryItems/32914FCA-B'34-449C-9DC3-127A259D94EA/1''2'7ae_t.jpg' /var/tmp/folders.29234/TemporaryItems/32914FCA-B'34-449C-9DC3-127A259D94EA/1''2'7ae_t.jpg
```
This is half the solution. The real path to the original item is more like /joesRHDD/Mountains/2''7'8'3/blackmountain/1''2'7ae_t.jpg so the actual command I want to run is 
	
	



```
exiftool -UserComment='/joesRHDD/Mountains/2''7'8'3/blackmountain/1''2'7ae_t.jpg' /var/tmp/folders.29234/TemporaryItems/32914FCA-B'34-449C-9DC3-127A259D94EA/1''2'7ae_t.jpg
```
 ie for the Lightroom copy of the original images, insert the original images path into the lightroom copys metadata. 
*Question:* Using Lua how can I find the Original Images Path at the time of export? Is that even Possible? All references to filename refer to the copy of the image that Lightroom has made. 
My Lua code changes made into the Lightroom to Gallery Plugin: in the file GalleryRemoteProtocol.lua , function uploadImage

```
-- note imagePath is a paramater passed to the function
local cmd = [COLOR=#dd'''']"exiftool -UserComment='"[/COLOR] .. imagePath .. [COLOR=#dd'''']"'"[/COLOR] .. imagePath
local returnval = LrTasks.execute(cmd)
```
*Options:* One option is to run the exiftool on the entire Removable HDD with the option "-overwrite_original" which screams danger as there is no backup of this drive. 
Also no need to do then entire 6''''+ images. Just the 1''' in the selections.

Thanx for the assistance.


----------



## Bruce J (Feb 28, 2008)

Jonathon Batson said:


> *Options:* One option is to run the exiftool on the entire Removable HDD with the option "-overwrite_original" which screams danger as there is no backup of this drive.
> Also no need to do then entire 6''''+ images. Just the 1''' in the selections.



Perhaps you can use LR to add a unique bit of text to one of the metadata fields for all of the images in the selection.  Then, when you run EXIFTool, use an IF clause to only operate on those images.  That would prevent you from modifying all 6'''' images.  Don't know what to suggest about the lack of a backup; seems as if no matter what you do, you're performing without a net.  What's your plan if the HD fails?  Good Luck,


----------



## Mark Sirota (Feb 28, 2008)

Jonathan, I did see a comment from Jeffrey Friedl on his blog somewhere that the path to the original file is not visible from the Export SDK, unfortunately.

Will the filenames be unique?  It would be expensive, but perhaps you could find the original file by actually searching for it, based on knowledge of the naming convention?


----------

