Writing An Aperture Edit Plugin - Part 1

July 16th, 2008

I have a need to start working on an Aperture Edit plugin for personal reasons. For the next two years I will be working towards an MFA in Photographic and Electronic Media at the Maryland Institute College of Art in Baltimore Maryland. During this experience I will be taking lots of pictures, and developing a long term documentary project. However, in addition to my traditional work, I will be adding a component to my exhibition and thesis that has to do with the visualization of my images.

You can read more about this at the website I have set up to document my project at Entropy Art.

Using an Aperture Edit plugin to manage my digital image processing makes perfect sense to me. I can create a suite of routines, have them be customizable in any way I want, and have them directly integrated with Aperture. This will keep my workflow simple and will keep all of my images and thesis work in one place.

As well, using Aperture allows me to take full advantage of all of the built in digital image processing libraries that come with Mac OS-X. These include the Core Graphics and Core Image libraries as well as OpenGL. In addition to these native frameworks I can integrate other very rich image processing libraries in Python using the Python Objective-C bridge.

In a nutshell, with an Aperture Edit plugin, I can create just about anything I would be able to do in a standalone application, but have it directly tied to my images and their metadata from Aperture.

As part of the Entropy Art project, this plugin will be written openly. I will be making the code available to all, and if you are a developer you will also be able to contribute to it and offer suggestions if you would like.

I have been writing Aperture Export plugins for some time now, but have never delved into an Edit plugin. I also don’t have the clearest idea of what it is I would like my plugin to do at this point. But, these things will come with time and with need.

So, I will be documenting this process here in a series of articles. Each article is not meant to be a tutorial exactly, but more of a documentation of my work. So please be prepared for some errors, some learning, and some missteps along the way.

Getting Started

The first thing I need to do is get my plugin template set up. Since I have been working with Aperture Export plugins I don’t need to do much, but if you have never done this before you will need to download the latest version of the Aperture SDK, which is available online at developer.apple.com. The SDK is free, but you must sign up at least as a free member for ADC.

Once you have downloaded and installed the SDK you can get started creating a template. In Xcode, select New Project from the File Menu and choose Aperture Edit Plugin under Standard Apple Plug-Ins.

For my plugin I chose the name Visualize. This creates a folder called Visualize containing all the files I need to get started. Xcode opens the project for me and I can see my list of files in the main part of the screen, along with my project’s “Groups and Files” in the left section.

In the next chapter of this series I will go over in depth the purpose of each of these files, but for now just notice the two main files named after whatever you called your project. In my case these are Visualize.m and Visualize.h. These are the files we will be working with for the most part, and will control most of what our plugin does.

Setting Up The Info.plist File

One of the first things we will need to do will be to make a few basic entries to our Info.plist file. This file contains a number of important properties having to do with our plugin. The one property we must edit is our unique identifier. Towards the bottom of the file you can see a group called ProPlugPluginList. If we open this up we can see a space that says “PUT A UUID HERE.” So first we need to get a new UUID. To do this, open a Terminal window and simply type “uuidgen” without the quotes. This will create a long sequence of letters and number which you can copy and paste into your Info.plist file.

I also change my Bundle Identifier property to reflect my company name, but this is about all we have to do at this point. Our plugin is now able to compile. To test it, we can hit the Build button and it should succeed without any errors.

If we want, we can even drag our newly built plugin into our Aperture Edit plugins folder and try starting it up in Aperture. However, going through this process every time you want to test your plugin can get a little annoying.

To make things easier we do the following steps. First we need to add Aperture as a new Custom Executable to our Xcode project. Simply control-click the Executables” tab under Groups and Files and select “Add New Custom Executable.” A dialog box will appear asking you to choose a file. Simply navigate to your Applications folder and select Aperture.

Next we need to add a script that will automatically build our plugin in the correct place and launch Aperture. To do this, click the tab in Groups and Files called Targets and then open your projects target so that you can see all of its build phases. Control-click the target and select Add –> New Build Phase –> New Run Script Build Phase.

A dialog box will appear. All you need to do is copy the following shell script into the dialog box as shown in the diagram, and close to dialog box.

# clean up any previous products/symbolic links in the target folder
if [ -a “${USER_LIBRARY_DIR}/Application Support/Aperture/Plug-Ins/Export/${FULL_PRODUCT_NAME}” ]; then
rm -Rf “${USER_LIBRARY_DIR}/Application Support/Aperture/Plug-Ins/Export/${FULL_PRODUCT_NAME}”
fi

# Depending on the build configuration, either copy or link to the most recent product
if [ “${CONFIGURATION}” == “Debug” ]; then
# if we’re debugging, add a symbolic link to the plug-in
ln -sf “${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}” \
“${USER_LIBRARY_DIR}/Application Support/Aperture/Plug-Ins/Export/${FULL_PRODUCT_NAME}”
elif [ “${CONFIGURATION}” == “Release” ]; then
# if we’re compiling for release, just copy the plugin to the Internet Plug-ins folder
cp -Rfv “${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}” \
“${USER_LIBRARY_DIR}/Application Support/Aperture/Plug-Ins/Export/${FULL_PRODUCT_NAME}”
fi

That’s about it. Now we should be able to select “Build and Go.” This will build our plugin and launch Aperture. Xcode will give us support for debugging in this mode as well, so it is a very useful way to work.

I try this myself and when Aperture launches I can see my Visualize plugin listed under “Edit With.” However, when I click it, nothing happens. This is because I haven’t told it to do anything yet. I still need to connect my user interface to my code, and I still need to tell my code to do something when I launch the plugin.

At this point however, I am ready to add my project to a revision control system like Subversion so that I can track all of my changes along the way. I can also take a look at the sample edit plugin that came with the SDK to get an understanding of how this should all work.

In the next part of this series we will talk a little about setting up revision control and then we will jump right into the first steps in designing and displaying our user interface, so stay tuned!


This entry was posted on Wednesday, July 16th, 2008 at 6:56 am and is filed under Developers, Micah Walter, Projects. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

5 Responses to “Writing An Aperture Edit Plugin - Part 1”

  1. Brendan Falkowski Says:

    Really looking forward to this series, I’ll be following along. Just need to buy a Mac so I can install + test + actually use Aperture.


  2. Micah Says:

    I’m just about done with part 2…


  3. Chuck Grieves Says:

    I get an error from the build results like so:
    Building target “Visualize” of project “Visualize” with configuration “Release” - (1 error)
    Running custom shell script (1 error)
    line 3: [:/Users/chuck/Library/Application: binary operator expected
    Build failed (1 error)

    I’ve copied and ran through your setup twice exactly but same error - I’m on Leopard 10.5.4 with Xcode 3.0. I’m curious if my system being a PPC instead of an Intel has anything to do with the error. Any help would be appreciated.


  4. Chuck Grieves Says:

    Update to previous:
    I removed the Run Script and then recompiled without error. I then copied the Visualize.ApertureEdit file to the ~/Library/Application Support/Aperture/Plug-Ins folder. On Aperture startup, I was able to see the plug-in as being available, but when selected, nothing occurred. No indication that the plug-in was activated to run at all.


  5. Chuck Grieves Says:

    Which just means that I’m now ready to add the code for my plug-in (see last comment) and it is working as expected. As far as the script, I can do with out it. Thanks for the info on getting started with this project.


Leave a Reply