Tips

Editing version names and other news

Since I put this site up I have had a few people ask me for assistance with a script they are writing to automate Aperture. First, let me say I'm happy to hear users of Aperture are interested in automating Aperture as well as find this web site useful. And secondly, I am happy to help improve the content of this site using reader feedback.

A while ago I received a request for help from a reader/user that wanted to change an image version's Exif Image Date by 2 minutes. After thinking about the solution of his problem I realized that this script is far more useful than changing the Exif Image Date by 3 years. So I decided to remove my time shift script on the Metadata page that incremented the image date by 3 years with a script that will add 1 hour to the image date. Why not 2 minutes? Because I want to not only illustrate how to time shift but also provide a useful script to a wider audience. I assume more people will want to change their images' date in increments of an hour to deal with daylight savings time or a change in time zones than will want to change the minute or second. Either way, the modification required is very slight.

Another reader/user recently asked me a question concerning a script he was writing that will remove the file extension from the name of the image version. I thought it was strange that Aperture somehow placed the file extension in the image version name. After playing around with Batch Change, I realized if you change the image version name to the master filename, the images will be named something like: filename.cr2

Since some users of Aperture may see this as a problem and it can be created within the GUI of Aperture, I decided to a script that will get a selection of images and remove a file extension from the version name. You will need to modify the script so that it finds the particular file extension you want found. For those that may not realize where to change the script to handle your individual needs, I left a comment just below the line that should be modified. Enjoy.

Click to open example in the Script Editor applicationRemove file extension from the version name.

 tell application "Aperture"
 set imgSel to (get selection)
 end tell

 if imgSel is {} then
 
error "Please select an image."
 
else

  repeat with i from 1 to count of imgSel
 
set imgName to name of item i of imgSel
 
set newimgName to findAndReplace(".CR2", "", imgName)
 
--Replace .CR2 with the string you want to remove.

 
tell application "Aperture"
 
tell item i of imgSel
 
set name to newimgName
 
end tell
 
end tell
 
end repeat
 
end if

 
on findAndReplace(tofind, toreplace, TheString)
 
set ditd to text item delimiters
 
set text item delimiters to tofind
 
set textItems to text items of TheString
 
set text item delimiters to toreplace
 
if (class of TheString is string) then
 
set res to textItems as string
 
else -- if (class of TheString is Unicode text) then
 
set res to textItems as Unicode text
 
end if
 
set text item delimiters to ditd
  return res
 
end findAndReplace


DISCLAIMER: I outright stole the find and replace function from Nigel Garvey which was posted a forum post on MacScripter. Since it was posted on a forum of a site devoted to learning AppleScript and this site does not collection money, I assumed I was ok to posted the function here.

Export command and selection property

I recently received an email from a visitor wondering why his export script produced an error when attempting to export a single image out of Aperture.

From his email I realized I omitted a few valuable simple scripts from my collection of sample scripts that would have helped him answer several of his questions. Therefore I'm happy he emailed me as his feedback helps to improve this site.

I failed to have a simple selection script and a very simplistic export script. Both scripts have been added to the site. The selection script can be found at the bottom of the Basics page. And the new export script can be found at the top of the Exporting page.

One other thing I failed to mention about exporting images is the export command only handles lists of image versions. Attempting to export a single image will produce an error which was the root of the visitor's problem.

If your script generates an error but you feel everything should work, be sure to take a close look at the Applescript Dictionary for Aperture. The dictionary should provide all the necessary information to successfully use a command, class, or property. In this particular case the dictionary does state the export command exports a "List of image versions or projects to be exported." Overlooking something such as this is easy to do.

Photoshop Droplets as External Editor

Although this tip has nothing to do with Applescript, it does involve Aperture and automating image processing using a 3rd party application.

One of the nice features of Photoshop is its batch processing of images and its ability to run recorded actions. The two combined together allow a user to apply the action against a directory of images or already opened images. Photoshop then allows a user to save a batch process along with an action using what Adobe calls “droplets”. The user can drop images or directories on the droplet and Photoshop processes those images using the instructions found in the recorded action.

Earlier today I created a droplet in Photoshop and saved it to my desktop. I then launched Aperture and made the droplet I just made as my external editor. The desire is to select a group of images in Aperture and have Photoshop process them using my droplet. I thought this would be really handy for preparing an image for printing or maybe I wanted a series of filters applied to the image. With Aperture 2.1, it seems as though the last image in the selection is the only one that Photoshop processes.

Although I wanted the entire selection in Aperture to be processed using the Photoshop droplet, this idea can still save a few mouse clicks. Without using this tip, you would have to instruct Aperture to open the selection in Photoshop. Once that is completed you then have to tell Photoshop to process the opened images using your action. Granted the time and effort savings isn’t terriby substantial although it could be if you were processing hundreds of images. One benefit of using a droplet as an external editor is images are handled one at a time by the droplet which is great if your images are large (imagine opening 20 200 MB TIFFs at once with 2 GB of RAM versus 1 image at a time using the same system configuration). If and when Apple addresses the problem and allows Aperture users to process multiple images using Photoshop droplets, this tip will save even more time and effort.

Adobting Aperture

One thing that bothers me about Aperture, Microsoft’s Expression Media (formly iView Media Pro), and Adobe’s Lightroom is neither company has what I call “transition tools”. How do I go from whatever solution I’m using now to adobting your grand new image management application?

Because of XMP support, Expression Media and Lightroom probably are farther along than Aperture (yeah I know Aperture can read embedded XMP and can output XMP files but that output is limited and Aperture can’t read XMP sidecar files). However as far as I know neither Adobe nor Microsoft help current film users, users of a competitor’s product, users of even a custom made database, etc etc etc to switch to their solution. I’m surprised users go through with the move anyway, myself included.

Not all is lost when trying to move to Aperture, you just have to do some of the grunt work yourself. Say you want to move from Expression Media to Aperture or Lightroom to Aperture but you want to save all your metadata. Well first of all, your Lightroom adjustments will not work with Aperture because Adobe and Apple don’t use the same adjustments nor write the data to disk the same way. However your IPTC and custom metadata can careover to Aperture.

I’m not going to tell you exactly how to go about it. However, I will tell you the answer lies in the usage of Applescript, a tool named, exiftool, and the XMP sidecars. exiftool is the Swiss Army knife of metadata tools and among many other things it can read and write XMP files. So the idea is to read data from an XMP sidecar file for a particular image found in a directory, store it, then find that same image within your Aperture Library, you then write that data to the appropriate field within Aperture using Applescript. Of course this is probably not the only answer to the problem, perhaps others exists. This is just one I have discovered.

If you feel like going down this path, be sure to get a copy of the Exif v2.2.1 specification and the IPTC specification for IIM (Aperture 2.x does not yet support IPTC Core. Because of this you may end up losing some data, but you could keep it around by using custom fields. Not exactly ideal, but worth thinking about.). The specs may help you map out the fields between the applications as well as map the fields within the XMP file.