iPhoto to Drupal via AppleScript and PHP

NOTE: I’ve released an updated version of this script that uses AppleScript only.

Here’s a hack I threw together to allow me to post images from iPhoto into my Drupal image gallery. It’s a two-step process: first, there’s an AppleScript that grabs the photo information from iPhoto and puts it into a temporary file; this script then calls a PHP script that takes this information and uses cURL to do an automated login to my Drupal site and uploads the photo.

There are probably much more elegant ways of doing this, but this one has the advantage of being relatively simply and easy to modify.

Here’s what you’ll need to make this all work:

Once you’ve got all of the above downloaded, installed, and configured, uploading a photo from iPhoto to Drupal is as simple as selecting a photo, and then selecting the iPhotoToDrupal script from the Script Menu:

Note that you’ll need to have at least an image “title” defined in iPhoto, as this is a required field in Drupal; an image description is optional.

Assuming everything is configured properly, you should find the selected photo uploaded to your Drupal image gallery a few seconds later.

I welcome comments on the code and the approach.

Comments

Steven Wittens's picture
Steven Wittens on February 7, 2005 - 05:14

Instead of converting to ISO-8859-1 you should convert to UTF-8 instead. I’m not 100% sure, but I think “UNICODE-2-0” refers to UTF-16.

moshe weitzman's picture
moshe weitzman on February 8, 2005 - 15:47

nice script!

oliver's picture
oliver on February 9, 2005 - 01:58

Is that photo in your post a picture of hardened lava from National Geographic, by any chance?

Add new comment