iPhoto to Drupal via AppleScript and PHP

Peter Rukavina

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

Submitted by Steven Wittens on

Permalink

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.

Add new comment

Plain text

  • Allowed HTML tags: <b> <i> <em> <strong> <blockquote> <code> <ul> <ol> <li>
  • Lines and paragraphs break automatically.

About This Blog

Photo of Peter RukavinaI am . I am a writer, letterpress printer, and a curious person.

To learn more about me, read my /nowlook at my bio, listen to audio I’ve posted, read presentations and speeches I’ve written, or get in touch (peter@rukavina.net is the quickest way). 

You can subscribe to an RSS feed of posts, an RSS feed of comments, or a podcast RSS feed that just contains audio posts. You can also receive a daily digests of posts by email.

Search