Aperture, Journal, Photography

Aperture and iView Auto Complete

A post on Rob Galbraith’s led me to discover where Aperture is storing its auto-complete items for Keywords and IPTC fields.

Although Annoture copies keywords/people from iView media items to Aperture image versions, the keywords/contacts are not copied over to the autofill lists. Aperture keeps a list of keywords and autofill items here:

~/Library/Application Support/Aperture/Keywords.plist

iView 2.6.4 and 3.0.x maintain lists in two different places:

~/Library/Application Support/iView/Plug-ins/Favorites/
~/Library/Application Support/iView/Plug-ins/Vocabulary/

It wouldn’t take much to convert iView keywords to Aperture keywords and back, although going from Aperture->iView, you won’t get the hierarchical keywords. Note that Aperture has two types of keyword support, it’s hierarchical keywords system and an IPTC keywords property that appears to be used when importing already annotated images.

~/Library/Preferences/com.apple.Aperture.plist is chock full of interesting preferences. I’m going to enjoy looking through all of the properties to help improve my applications.

Well, it’s not as easy as I thought it was going to be. Such is life when scripting Aperture

I was able to write a script that adds People from iView to Aperture’s iptcProperties.Contact.Completions property in the com.apple.Aperture.plist preference file. Inspecting the file in Property List Editor shows that the items were copied correctly.

Restarting Aperture shows that only the first nine or so annotations are used in the auto-complete. If I start typing the first few characters of the 10th item, auto-complete does not happen

Furthermore, quitting the application changes the value of iptcProperties.Contact.Completions, removing all of the items we just added from iView!

Here’s the current script that I’m using for testing purposes.

property aperturePrefPath : "~/Library/Preferences/com.apple.Aperture.plist"
property apertureKeywordsPath : "~/Library/Application Support/Aperture/Keywords.plist"
property libraryPath : path to library folder from user domain as string
property iView2Aperture : {{"People", "iptcProperties.Contact.Completions"}}

set iView2Path to libraryPath & "Application Support:iView:Plug-ins:Favorites:"

-- This script runs with iView 2.6.4. iView 3.x users will have to modify
-- the script to work on their systems

on iViewCompletionsToAperture()

	tell application "System Events"
		set aperturePrefs to property list file aperturePrefPath
	end tell

	repeat with anItem in iView2Aperture
		set iViewPrefsFilename to iView2Path & first item in anItem
		set apertureIPTCProperty to second item in anItem

		set theList to iViewGetCompletionList(iViewPrefsFilename)

		-- now replace aperture's completion prefs with iView's
		-- we could do a union, but this is a quick and dirty method

		if theList is not {} then
			tell application "System Events"
				set value of property list item apertureIPTCProperty of aperturePrefs to theList
			end tell
		end if

	end repeat

end iViewCompletionsToAperture

on iViewGetCompletionList(theFilename)
	set theList to {}

	-- read the contents from the iView preferences file
		set theContents to ""
		set fp to open for access (alias theFilename)
		set theEOF to get eof fp
		set theContents to read fp until theEOF

		if theContents is not "" then
			set AppleScript's text item delimiters to return
			set theList to text items of theContents
			set AppleScript's text item delimiters to ""
		end if
		close access fp
	on error
			close access fp
		end try
	end try

	return theList
end iViewGetCompletionList


I’ll try now with Aperture’s hierarchical keyword list. Maybe things will be different for that since those preferences are not stored in com.apple.Aperture.plist.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s