Export image for selected Address Book card

An AppleScript that will export the image file associated with an entry in Address Book.

There is no error handling, so if you have multiple (or zero) cards selected, or a card with no image, nothing will let you know it didn’t work.

Also, the ideal way to launch this script would be from Address Book’s script folder ( ~/Library/Scripts/Applications/Address Book ).

set tmp_image to ((path to temporary items folder as text) & "tmp AB") as string
tell application "Address Book"
  set this1 to selection as reference
  set file_name to name of this1
  set the_image to image of this1
    set AB_image to (open for access tmp_image with write permission)
    set eof AB_image to 0
    write the_image to AB_image
    close access AB_image
  on error
    close access AB_image
  end try
  set the_image to ""
  set the_file to choose file name with prompt "Save as" default name file_name & " AB image.tiff"
end tell
tell application "Image Events"
  set this_image to open (tmp_image) as string
  set the_file to the_file as string
  save this_image in the_file as TIFF
  close this_image
end tell

Leave a Reply

Your email address will not be published. Required fields are marked *