Applescript

Aperture: 2.0.1 Brings New Applescript Features

Apple's Applescript pages are showing how new features introduced by Aperture 2.0.1 allow integration with Adobe InDesign CS3. By fingerprinting images with a number in a metadata field, applications that receive previews have, via Applescript, a away to get the original. InDesign uses this to work with previews as proxies until the document is exported for print. At that time the originals are retrieved and put into the final document. There are two short videos that show how it is done.
|

Aperture Caption: An Applescript To Quickly Caption Images

aperturecaption
Adam Tow has posted an Applescript called Aperture Caption that allows captioning of a series of images without all that frustrating switching between the mouse an the keyboard. You can use FastScripts Lite to create a keyboard shortcut for invoking it, so removing even more mousing.
|

Aperture: Applescripts To Extract Metadata

extractcustommetadata
Berend Hasselman has a page dedicated to Aperture scripts he has put together. He needed to get at the metadata that Aperture stores but doesn't give access to, like Lens ID and Auto Focus point used so created these scripts. They run fine under Tiger and Leopard.
|

Sal Soghoian on Leopard, Automation, and Aperture

O'Reilly has posted another Inside Aperture podcast: Sal Soghoian talking about Leopard, Automation, and Aperture. Don't miss the previous shows listed in the sidebar, or simply subscribe to the podcast in iTunes.
|

Leopard: NSOperation and NSOperationQueue Example

Drew McCormack at MacResearch has a nice example of the power of NSOperation and NSOperationQueue. His example carries out matrix calculations using multiple threads by setting up an NSOperation to evaluate each part of an expression tree.

Usually it is hard to use CPU resources efficiently and reliably, but these new features of Leopard make it simple. By packaging compute-intensive operations into NSOperation objects all the complexity is handed off to the operating system.

Notable in this example is that there is no code for locking. That's all handled automatically. There is also no code to manage dependencies between parts of the expression that are being evaluated on multiple threads and potentially multiple CPUs. Dependencies are expressed in the code, but not explicitly managed.

Since this is Objective-C 2.0 you can also see @properties and @synthesize at work. And marvel at the lack of memory management.

The site also has many other goodies for people using Macs for scientific environments including a script repository, and a Core Animation tutorial.
|

Extending Aperture 1.5

Apple has a 32 minute seminar on extending Aperture posted on their site. It looks at Applescript, Automator, export plug-ins, and iLife integration.
|

Applescripts Galore for Aperture

IMG_1384-2007-08-25
Hummingbird on a wire: 1/640s f/11.0 ISO400 195mm, Canon 30D, EF 70-200 f2.8 L IS, adjusted

Brett Gross has a sizable collection of very useful Applescripts for Aperture on his site. They include functions for helping with hierarchical keywords, backing up to DVD, managing multiple external editors, syncing folders and projects, and many more.
|

Add Additional EXIF Data To Aperture Images

By gluing together exiftool, Applescript, Perl, and Aperture Allan Hise and Brett Gross have created a solution to the problem of missing EXIF data in Aperture by adding it automatically as part of the import.

I have this problem myself: the Canon S3 does not put useful ISO data in a standard place and so I have no ISO data for my images. Other people want to import GPS data, lens data, and other information that sits uselessly in their images, unavailable to Aperture.

To add data to images already in Aperture he has this tool.
|

Aperture: Speed Up Aperture By Rebuilding The Database Index

databasereindexicon
Everyone is excited about the discovery of using the sqlite vacuum command to rebuild the index for Mail.app. Well the same trick works for Aperture. Rebuilding the library database indexes is much faster than rebuilding the entire database. While probably not as effective, it does improve the speed of Aperture, especially for heavily-used libraries with a lot of deleted images. [Update: Aperture 2.0 has two databases: the Aperture.apdb database and a new one called BigBlogs.apdb. As currently written, this script does not touch the BigBlobs database.]

Here is the script. You can download a ZIPped version from the download page or paste the text below into Script Editor. Be careful of the single- and double-quotes getting modified in the process. They are all straight quotes. [Update: I added an improvement sent to me by Adam Tow. The script now only opens bundles and defaults to the Pictures folder.]

tell application "Aperture" to quit

set new_file to choose file with prompt "Select Aperture Libary to compact its database" default location (path to pictures folder) of type {"BNDL"}
set libname to (POSIX path of new_file) & "Aperture.aplib/"
set dbname to libname & "Library.apdb"
set sizeBefore to do shell script "ls -lah " & (quoted form of libname) & " | grep -E 'Library.apdb$' | awk {'print $5'}"

do shell script "/usr/bin/sqlite3 " & (quoted form of dbname) & " vacuum"

set sizeAfter to do shell script "ls -lah " & (quoted form of libname) & " | grep -E 'Library.apdb$' | awk {'print $5'}"

display dialog ("Database before: " & sizeBefore & return & "Database after: " & sizeAfter & return & return & "Now try it out!")

After prompting to select an Aperture library, it runs for a while (up to a minute on large libraries) and then shows a dialog box comparing the size of the library database before and after processing:
databasereindex
Let me know how much it helps.
|

Change Aperture Libraries with Applescript

Allan Marcus has contributed this handy Applescript to the Apple discussion boards. Compile and save it as an application using Script Studio, then drop onto the icon the Aperture library you want Aperture to open. If you double-click on the icon, Aperture will open.

on open (theFiles)
set lib to quoted form of POSIX path of theFiles
if isAppRunning("Aperture") then
tell application "Aperture" to quit
end if
repeat while isAppRunning("Aperture")
delay 1
end repeat
try
do shell script "defaults write ~/Library/Preferences/com.apple.Aperture LibraryPath " & lib
end try
delay 1
tell application "Aperture" to activate

end open

on run
tell application "Aperture" to activate
end run

on isAppRunning(pAppName)
tell application "Finder"
set appIsRunning to process pAppName exists
return appIsRunning
end tell
end isAppRunning
|

Exporting From Aperture With Applescript

User ramonr posted the script below on the Apple Aperture forums. It exports all your images that are in albums in the project you choose. I've not tried it myself.

I have a generalized script - it assumes that any pictures are in albums (rather than in just subfolders) but it will walk you down as many levels as you have.

tell application "Finder"
set location_1 to (choose folder with prompt "Choose a folder to export into") as text
end tell

tell application "Aperture"
set x to name of every project
choose from list x with prompt "Choose a project to export"
set theP to item 1 of result
tell application "Finder" to make new folder at alias location_1 with properties {name:theP}
tell project theP
set initflist to every subfolder
set initalist to every album
if initflist is equal to {} then
processAlbums(initalist, location_1 & theP) of me
else
if initalist is not equal to {} then
processAlbums(initalist, location_1 & theP) of me
end if
processSfolders(initflist, (location_1 & theP)) of me
end if
end tell
end tell

on processAlbums(alist, apath)
tell application "Aperture"
repeat with a in alist
tell a
set theimages to every image version as list
set thename to name of a
tell application "Finder"
if not (exists folder thename in alias apath) then
make new folder at alias apath with properties {name:thename}
end if
set destination to apath & ":" & thename & ":"
end tell
with timeout of 6000 seconds
tell a
set settings to "JPEG - Original Size"
export theimages using settings to alias destination
end tell
end timeout
end tell
end repeat
end tell
end processAlbums

on processSfolders(flist, fpath)
tell application "Aperture"
repeat with a in flist
set thename to name of a
tell application "Finder"
if not (exists folder thename in alias fpath) then
make new folder at alias fpath with properties {name:thename}
end if
end tell
tell a
set sAlist to every album
set sflist to every subfolder
if sflist is equal to {} then
processAlbums(sAlist, fpath & ":" & thename) of me
else
if sAlist is not equal to {} then
processAlbums(sAlist, fpath & ":" & thename) of me
end if
processSfolders(sflist, fpath & ":" & thename) of me
end if
end tell
end repeat
end tell
end processSfolders
|
The Bagelturf site welcomes Donations of any size