schussman.com logo

Sync Lightroom Galleries to Android - Automatically!

Now that I have a photogenic, tiny gurgling creature in the house, I’m shooting a lot of photos, both on the Droid X and the Pentax. Most of these photos end up, one way or another, in Lightroom for cataloguing, and as I’ve described earlier, I have a nice workflow for updating these rapidly-growing galleries on my iPad.

But how about the Droid X? It has a nice screen, and I want to foist photos of my beautiful boy on anyone I happen across — so I started to wonder if, continuing to use Lightroom as my core platform, I could keep a small gallery of photos on the Android phone with as little manual work as possible.

Here’s the executive summary: I again use a smart published collection in Lightroom to create the gallery; then I use a LaunchAgent in OS X to monitor the mount point of the Droid X on the filesystem; and a tiny shell script syncs the published gallery to the Droid whenever I plug it into the MacBook Pro. Read on for altogether too many details.

First, a couple of things to note about how the Droid X generates image galleries [ note that this may apply to all Android devices; I have no idea, and your mileage may vary ]:

  • Android automatically displays galleries based on image type — so you don’t need to update a database or anything to build your galleries on the phone. You just need folder(s) full of images.
  • When you run the Gallery app, it will display galleries with the name of the parent folder containing the images. This means you can make a folder tree on the Droid’s SD card and neatly package multiple gallery folders within it, without cluttering up your root directory.

Prepare the SD card

When I attach my Droid X via USB to the MacBook Pro, it automatically mounts it as a volume titled NO NAME, so I used the Finder to change the label to DROIDX. This, happily, seems not to have affected any of the phone’s operations; the Droid must not depend on the name of the SD card for any of its internal work.

The second preparation step is to create a master gallery directory on the SD card. This is just for housekeeping purposes; everything in the galleries will be in a subdirectory of that top-level directory. Again, I simply did this with the finder: navigate to the DROIDX drive when the phone is connected, and create a new top-level directory, Galleries.

Your SD card and Droid should now be ready to go.

Set up the Gallery/Galleries

Just like last time, I’m using smart publish collections, based on keywords, to populate the galleries that will be synced. I decided to prefix all the keywords for this usage with dx — so, dx-gallery is my main tag, and I’ve edited it in LR to not be included in export. It’s a housekeeping tag only.

I’ve tagged a bunch of images with the dx-gallery tag.

Then it’s off to build the publish service. Here’s what it looks like in the publishing manager:

And add to that service a Published Smart Set that looks like this:

You can assign multiple keywords to the Smart Set, or create as many smart sets as you want galleries, and use unique keywords to assign photos to each. Each smart set within the published collection will appear in your directory tree as a subdirectory of the top-level folder for the set — and that makes the syncing to the Droid easy.

Automate syncing via LaunchAgent

Everything I know about LaunchAgent I learned from this tutorial. This is basically a concise repeating of that description, edited for our purposes. (I’ve previously described using this process to perform system backups)

First, if it’s not already there, mkdir ~/Library/LaunchAgents. This is the folder that OS X will watch for scripts triggered by system events such as mounting an external drive, which is exactly what plugging in the Droid does.

In that directory, make a new plist file (I called mine droid-sync-watch.plist) and give paste this into it:

<?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC “-//Apple Computer//DTD PLIST 1.0//EN” \ “http://www.apple.com/DTDs/PropertyList-1.0.dtd”> <dict> <key>Label</key> <string>droid-sync</string> <key>LowPriorityIO</key> <true/> <key>Program</key> <string>/Users/alan/Library/Scripts/droid-sync</string> <key>ProgramArguments</key> <array> <string>droid-sync</string> </array> <key>WatchPaths</key> <array> <string>/Volumes</string> </array> </dict> </plist>

In short, this plist file tells the OS to run the identified script (~Library/Scripts/droid-sync) when the specified WatchPath changes.

The sync script itself lives in ~Library/Scrips and consists of a check against the desired volume (here’s where naming the Droid SD card comes in) and an rsync of the designated published collection to the previously-generated target directory on the SD card.

#!/bin/bash # delay a short time to make sure the path is available echo -n "[*]-- new /Volumes... sleeping" | logger sleep 20 if [ ! -e "/Volumes/DROIDX" ]; then       echo -n "[*]-- DROIDX NOT connected - Exiting" | logger       exit 0    else       echo -n "[*]-- DROIDX Connected - Performing gallery sync" | logger fi # rsync with delete option rsync --delete -r ~/Pictures/Exported\ Photos/Droid/ /Volumes/DROIDX/Galleries echo -n "[*]-- DROIDX gallery sync complete" | logger

Finally, tell the LaunchAgent controller to watch your scripts by doing the following at a terminal:

  • launchctl load ~/Library/LaunchAgents
  • launchctl list | grep sync

You should see your droid-sync script appear in the list produced by the second command, above.

Now you’re ready!

Plug in and go

That really should do it. When you connect the Droid X, you can watch the messages in the sync script appear in your console log, and everything should work — after syncing, disconnect the device again and fire up the gallery application; in the “Folders” section of the gallery you should see an item for each gallery you create in Lightroom. You’re done!

As with the iPad workflow, the great part of this is that once it’s set up, it’s pretty automatic. If you edit, add, or remove photos, as long as you republish the collection, those changes will all be pushed over to the Droid. Thanks to a little nerdery and Lightroom, we’ve built a bit of functionality that the Droid software doesn’t directly offer — and it’s still done with LR as the core of the photo library.

Lightroom 3 to iPad gallery workflow

(Or, an efficient way to use Lightroom to manage photos on your iPad)

I got myself an iPad a few weeks ago. Short review: It’s a big iPhone only in the sense that an iPhone is just a phone; that is, it’s hawt and I love it. (More ZOMG iPad articles to follow, I’m sure.)

The iPad really shows off photos, so I’ve been thinking about the best way to manage the photos that I want to put on it. With the non-beta release of Lightroom 3 this week, I think I’ve found a start at a workflow in the new publishing service that it offers.

First a note about syncing photos to the iPad. Like the iPod/iPhone, you have to select a single parent directory, and optionally subdirectories, of photos that you want to sync. The iPad stores photos in a series of albums simply named after the subdirectory where they live on your hard drive. In my case, I keep the photos that I publish out of Lightroom in one of a number of subfolders of a ~/Pictures/Exported Photos directory, but I don’t necessary want to sync all of them to the iPad. And, for the iPad, I wanted a little more control over the album naming for purposes of navigation — so I didn’t want to keep the directory names I’ve previously used for simple file management.

So: I have an “iPad” directory in my exports folder, and that’s what I sync to the iPad — along with all its subdirectories. I’ve copied a handful of existing albums into that directory, which isn’t a great solution but it does work for now. Apple has apparently decided that symbolic links cannot be synced [that would be a great capability, wouldn’t it?], so I can’t simply create links to the file locations of the existing, non-Lightroom albums that I want to sync.

iPad sync directory; Lightroom 3 publish service directories are subfolders of this

But the Lightroom albums are another story. Right now, I’ve simply created a couple of Hard Drive publish services, each of which publishes to a subdirectory of that “iPad” folder I described above. For example, the current flickr one simply sets up a set of export parameters for photos that will be published to a subdir.

Lightroom 3 Hard Drive publish service setup

But the slick part comes by making a smart collection that will publish everything I post to flickr in 2010. Simply build the smart collection within the publish service:

Creating a published smart folder in Lightroom 3

And then set it to include all photos that match some key criteria: Since I use Jeffery Friedl’s flickr plugin, I can call directly on the metadata it creates at export:

Published Smart folder settings to include a subset of Flickr-published photos

I now have a smart collection within a publish service, so the photos that I export that match that criteria will automatically be added. I’ll have to occasionally republish to the service itself; and each time I do so, the iPad will gather up those photos the next time I sync.

You can use the same methodology to set up hard drive publish services for any album you like; each service will appear on the iPad as an album, and if you create a smart collection (or a series of them) as part of the service, then they’ll be updated automatically as you perform you regular photo workflow.

One final note on why I think the publish service is an ideal tool for this workflow, rather than a solution such as simply exporting to a folder: The publish service will apply future changes to the service settings to all photos under its control. So, were I to decide to apply a watermark, a border (via, for example, LR/Mogrify 2), or adjust photo quality in order to save space on the iPad, those changes made to the publish service would result in the option to re-process the current photos:

Publish service allows for the updating of all published photos when changes are made to the service

In a sense, then, the photos produced via the publish service are truly synced — future changes will be managed and will trigger re-processing, if I choose. I think that’s pretty Good Stuff.

Getting better all the time

Just noting: Strongspace now supports file syncing using unison. Cool. This increases the value of strongspace pretty significantly, allowing one to use the service to sync files among multiple machines with ease, something that tools like rsync or version control didn’t facilitate very well. (Unison v.2.13.16 required.)


About, the short version

I’m a sociologist-errant. This site is powered by Textpattern, Pair Networks and the sociological imagination. For more about me and this site, see the long version.

RSS feed