I was looking for a way to automatically add pictures to my Address Book, and have discovered some possibly useful bits of information. As with all empirical observations, your results may vary.
Apparently, Address Book (3.0.3) doesn't include picture information directly in its data files, nor are images directly accessible via AppleScript. Rather, it just puts any images you give it in ~/Library/Application Support/AddressBook/Images/, but with a cryptic name and format. The name of the image files seem to be based on the IDs that Address Book uses internally. You can access such IDs with AppleScript, eg, this script:
% osascript -e 'tell application "Address Book" to get id of person 1'
returns '15E7B9BC-C142-11D6-9F6E-0002979E861C:ABPerson' for me. The name that Address Book uses for an image file seems to be the ID of that person with the ':ABPerson' suffix stripped. I wasn't able to penetrate the image format that Apple uses by default, but jpg's (moved and renamed as just described - without a '.jpg' suffix) seem to display in Address Book just fine.
Using this information, one can take a folder full of "email@example.com" files, and automatically add those images to the people in a given group with those email addresses. Here's my successful if inelegant version:
tell application "Address Book" set the_people to every person in group "Work" set home to (do shell script "echo ~") set destination_dir to home & "/Library/Application Support/AddressBook/Images/" set image_dir to POSIX path of (choose folder with prompt "Choose an image directory:") repeat with this_person in the_people if email of this_person exists then set old_file to ((value of email 1 of this_person) as text) & ".jpg" set old_path to quoted form of (image_dir & old_file) set new_file to characters 1 through -10 of (id of this_person as text) as text set new_path to quoted form of (destination_dir & new_file) set my_command to "cp " & old_path & " " & new_path try do shell script my_command end try end if end repeat end tell
Now if I could only figure out how to get Mail.app to show these pictures...
[robg adds: I have not tested this one...]