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

moshe weitzman's picture
nice script!
Steven Wittens's picture
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.
oliver's picture
Is that photo in your post a picture of hardened lava from National Geographic, by any chance?
Peter Rukavina's picture
Peter Rukavina's picture
In the updated version of the script, I did away with text encoding conversion altogether, perhaps at my peril.

Post new comment

You can comment anonymously if you must, but I would prefer it if you used your real name.
The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
Optional. If you enter the address of a website here, your name will be publicly linked to the site.
  • Adds typographic refinements.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.