Also see the list of articles, none to be taken seriously.

Beach Ultimate

Every Thursday evening this summer, there’s a pickup Ultimate game at Narragansett Town Beach. This is what yesterday’s game (19 pictures) looked like.

Read and Post Comments

Catching up on photo collections I’ve posted in the past few weeks:

  • FireworksA 4-day camping trip in the White Mountains with the Appalachian Mountain Club Worcester Young Members, in which we hiked a few mountains, took turns jumping from a ledge into Emerald Pool, and watched the fireworks display at the Mt. Washington Hotel.
  • Blue Hills hikersMy Blue Hills beginner hike, which drew a huge crowd. I took the first 25 to sign up, and could run another trip with the rest.
  • Frank passing disc to SunyaThe RIPUL tournament, where a relatively low-ranked Ultimate frisbee team went to near the top, in spite of my presence on it.
Next up for this weekend:
Sat Aug 19 A Shoe, a Sock, a Rock: Monadnock (C3C) Waitlist
No, the title doesn’t make sense, but it did catch your attention. If you haven’t hiked Monadnock before, give it a try and find out why it’s now the most-hiked mountain in the world. This 4.5-mile loop near the southern border of NH is great for experienced hikers who like the views and beginners who like a challenge. Second in a beginner hike series.
Reg. at http://ashearer.com/personal/trips/register.php?tp=2006-08-monadnock. L Andrew Shearer. CLs Andrea Hafner, Tim Smith.
Read and Post Comments

AcadiaSee what Acadia National Park in Maine looks like. I took a trip there a couple of weeks ago with 17 people from the Appalachian Mountain Club Worcester Young Members (an unofficial event). Great biking, trail running, kayaking, and sunrise on Cadillac Mountain—see the pictures. Thanks to everyone involved for a memorable weekend.

Read and Post Comments

SnowThere was a snowstorm in Providence last December 9. Most people left work early and traffic was backed up for hours, so I took the scenic route, with a camera pointed out the window.

Read and Post Comments

Box below overpassBelow a Providence street as it crossed over the water, I once came across a large wooden crate-like structure hanging by heavy cables, only easily visible or accessible by boat. Liana Araujo-Lane saw my picture of it and wrote in with an explanation—thanks, Liana!

“I believe that that cardboard wood thing was a project of a student at RISD for a while. She lived in it and commuted to school with a kayak every day. she had to co-ordinate her commuting times with the tides…it was pretty interesting. I learned about this from a teacher I had over last summer at RISD who was friends with this girl.”
Read and Post Comments

Here’s a way to back up iPhoto’s image comments into an easy-to-read flat directory structure. (Translation: one big folder.) You’d want to do this when archiving your photos to CD or DVD, or when trying to merge photo libraries, or when leaving iPhoto for another program, or at any other time you want your comments saved in a non-proprietary, easily readable format.

As you may have read last week, when I upgraded to iPhoto 4, all the image descriptions temporarily disappeared from my online photo albums. (I caught the problem on my own staging server before it appeared on this site.) The culprit was a change in the way iPhoto stores photo comments. Comments are now entirely gone from the easy-to-parse AlbumData.xml file; iPhoto now stores them in a binary format that appears to be proprietary.

AppleScript to the rescue. Last week’s script saved the comments to text files and generated a directory structure that exactly paralleled iPhoto’s library, with one text file for each comment. These files were in folders for each day, which were in turn inside folders for each month, etc., guaranteeing there would be no name conflicts. I had rejected using the internal ID of each picture (which would have allowed a flat conflict-free directory structure) because the ID wasn’t user-visible anywhere in the iPhoto interface, making comment files named for the ID difficult to map back to the original pictures.

One of the comments on that post asked for a version that generated the comment files in one folder, based on the image’s filename. That was a good idea. Though the filename is not guaranteed to be unique, it often is in practice. Most digital cameras save unique serial numbers for each picture as part of the filename. So this is enough for most people. (The exceptions would be if you have more than one digital camera using a similar naming convention, or if your camera is configured to reset its numbering between rolls.)

If you like guaranteed accuracy, use my original script; if you like simplicity, use the following alternate script. It will only save one of the conflicting comments if photo filenames are duplicated. Dropping the parallel folder structure simplified the script, since this version doesn’t need to employ any POSIX path manipulation.

Copy the following into Script Editor and run. Tested with iPhoto 4.0 on Mac OS X 10.3. (It may also work with earlier versions; drop me a comment below if you’ve tried it.)

-- Export iPhoto Comments - Flat
-- Creates a text file corresponding to each picture with a comment, containing just the comment. The filenames of the text files correspond to the filenames of the images. So avoid having more than one image with the same filename (taken by two different cameras with similar naming conventions, perhaps). This isn’t a problem for most people, but if it is for you, use the slightly more complex version of the script that duplicates the iPhoto folder hierarchy: <http://www.shearersoftware.com/personal/weblog/2004/01/18/iphoto-4-has-comments-no-more>.
-- Note: this does not remove files in the comments folder when a comment disappears (due to deletion of either the comment or the image). To guard against this, you may want to delete the whole comment folder before rerunning this script. (Using a separate folder rather than storing comment files alongside the image makes this easier; you can flush the whole cache at once.)
-- Written to work around the fact that iPhoto 4 no longer stores photo comments in the AlbumData.xml file.
-- by Andrew Shearer, 2004-01-25 <mailto:ashearerw at shearersoftware dot com>

-- config
set commentsFolderName to "iPhoto Library - My Comments Cache - Flat"
set stripJPG to true --whether to strip .JPG extension
set openFolderInFinder to true
set commentFileSuffix to ".comment.txt"
set requiredAlbumPrefix to "Web-"
-- end config

tell application "Finder"
--return some folder of (path to pictures folder)
if not (exists folder named commentsFolderName of (path to pictures folder)) then make new folder at (path to pictures folder) with properties {name:commentsFolderName}
set commentsFolderPath to folder named commentsFolderName of (path to pictures folder) as text
end tell
--set commentsFolderPath to POSIX path of (path to pictures folder) & commentsFolderName

tell application "iPhoto"
repeat with theAlbum in (every album whose name starts with requiredAlbumPrefix)
repeat with thePhoto in (every photo of theAlbum whose comment is not "")
set commentText to comment of thePhoto as Unicode text
set commentFilename to image filename of thePhoto
if stripJPG then
-- strip .JPG suffix (optionally)
if commentFilename does not end with ".JPG" then
error "Error: file does not end with .JPG: \"" & commentFilename & "\""
end if
set commentFilename to text 1 through -5 of commentFilename
end if
-- add suffix to comment filename (.txt extension, etc.)
set commentFilename to commentFilename & commentFileSuffix

set f to open for access file (commentsFolderPath & commentFilename) with write permission
set eof f to 0 -- truncate file, or old data can remain
write commentText to f as Unicode text
close access f
end repeat -- photos in album
end repeat -- albums
end tell

if openFolderInFinder then tell application "Finder" to open folder commentsFolderPath
Read and Post Comments

In addition to the public England trip photos, the semi-private family photos are now up, so members on both sides of the Atlantic can see them equally easily. Use family for the username and my mother's maiden name as the password when you click this photo link.
Read and Post Comments

I bought the upgrade to the Apple’s iLife suite, released on Friday. Here’s a gotcha for developers who parse iPhoto’s AlbumData.xml file, though it doesn’t directly affect most users. It affects me, because my own code parses AlbumData.xml to generate my web-based photo albums (such as the England trip pictures I just posted).

Though the overall format of iPhoto’s XML file stays the same (and my script had no trouble reading it), the Comments and Date fields are gone! The Date field is renamed and in a different format, which is no problem to work around because the image file’s embedded EXIF data contains the date as well. The missing Comments field is a different story.

From my quick inspection, the comment data seems to be only stored in a newly introduced iPhoto.db file, which is in some binary format. The rationale for this is presumably performance, but that doesn’t completely make sense, since the photo title is still stored in the XML file and it may be changed just as often.

In any case, here’s a workaround that uses AppleScript to write a parallel folder structure holding just the comments, one per text file. Paste the following into a Script Editor window and run. Use this anytime you’d like to protect your comments from the vagaries of software or platform transitions or upgrades. (The parallel folder structure helps this; the script could have used iPhoto’s internal IDs and generated all the files in a single folder, but that wouldn’t have been as forward-compatible.) GPL-licensed.

-- Export iPhoto Comments
-- Creates a parallel folder structure to the iPhoto Library, with a file corresponding to each picture with a comment, containing just the comment.
-- Note: this does not remove files in the parallel folder when a comment disappears (due to deletion of either the comment or the image). To guard against this, you may want to delete the whole comment folder before rerunning this script. (Using a parallel folder structure rather than storing comment files alongside the image makes this easier; you can flush the whole cache at once.)
-- Written to work around the fact that iPhoto 4 no longer stores photo comments in the AlbumData.xml file.
-- For automatic folder creation, requires the BSD subsystem (which is installed by default).
-- by Andrew Shearer, 2004-01-18 <mailto:ashearerw at shearersoftware dot com>

-- config
set commentsFolderName to "iPhoto Library - My Comments Cache"
set stripJPG to false --whether to strip .JPG extension
set openFoldersInFinder to false
set commentFileSuffix to ".comment.txt"
set requiredAlbumPrefix to "Web-"
-- end config

set commonRootPath to POSIX path of (path to pictures folder)
set origFolderName to "iPhoto Library"
set origFolderPath to commonRootPath & origFolderName
set commentsFolderPath to commonRootPath & commentsFolderName

tell application "iPhoto"
repeat with a in (every album whose name starts with requiredAlbumPrefix)
repeat with p in (every photo of a whose comment is not "")
set imagePath to image path of p
set commentText to comment of p as Unicode text

if imagePath does not start with origFolderPath then
-- make sure image is inside iPhoto Library; otherwise we won't know where to put the comment file. This AppleScript comparison is case-insensitive.
error "Image does not appear to be inside iPhoto Library. Image path: \"" & imagePath & "\". Expected library path: \"" & origFolderPath & "\""
else
-- construct new path in parallel folder structure
set commentFilePath to commentsFolderPath & text from (1 + (length of origFolderPath)) to -1 of imagePath
if stripJPG then
-- strip .JPG suffix (optionally)
if commentFilePath does not end with ".JPG" then
error "Error: file does not end with .JPG: \"" & imagePath & "\""
end if

set commentFilePath to "" & text 1 through -5 of commentFilePath
end if
-- add suffix to comment filename (.txt extension, etc.)
set commentFilePath to commentFilePath & commentFileSuffix
-- create intermediate folders as necessary with mkdir shell command. Finder-based alternatives for this are awkward. +++ This code has not been checked for proper shell escaping, though it does at least enclose its arguments in double quotes.
do shell script "mkdir -p \"`dirname \"" & commentFilePath & "\"`\""
if openFoldersInFinder then do shell script "open \"`dirname \"" & commentFilePath & "\"`\""

-- rest of the code writes out the comment file
set commentFile to commentFilePath as POSIX file -- make into Mac filespec

set f to open for access commentFile with write permission
set eof f to 0 -- truncate file, or old data can remain
write commentText to f as Unicode text
close access f
end if
end repeat -- photos in album
end repeat -- albums
end tell
That’s the AppleScript code. The comments are now in a human-readable text format, and you could use a script such as this Python snippet to read a given picture’s comment:
commentCommonBaseDir = os.path.expanduser("~/Pictures/")
commentOrigDir = os.path.join(commentCommonBaseDir,
    "iPhoto Library")
commentParallelDir = os.path.join(commentCommonBaseDir, 
    "iPhoto Library - My Comments Cache")
commentFileSuffix = ".comment.txt"

def getCommentForFile(imagePath):
    if not imagePath.lower().startswith(commentOrigDir.lower()):
        raise ('Error: image does not appear to be in iPhoto Library; ' + 
           'cannot compute comment path. Image: "%s". Library: "%s".' ) \
           % (imagePath, commentOrigDir)
    commentPath = os.path.join(commentParallelDir, 
           imagePath[len(commentOrigDir)+1:]) + commentFileSuffix
    if os.path.isfile(commentPath):
        print "Read comment for " + imagePath
        return open(commentPath, 'r').read()
    return ''
Read and Post Comments

Here are pictures of the scenery in Dartmouth taken during my trip to England over the New Year. Uploading has been slow due to the sudden death of my cable modem. Family pictures are coming next, and are semi-private: you’ll need to enter "family" as the username and my mother’s maiden name in lowercase as the password. The aunts, uncles, and cousins involved should have no problem figuring that one out.

Read and Post Comments

Today’s hike up Mt. Monadnock in New Hampshire, with the the Boston AMC YM group: 25 pictures.

Read and Post Comments

Next Page »