Re: Photo ID from iPhoto Import?
Re: Photo ID from iPhoto Import?
- Subject: Re: Photo ID from iPhoto Import?
- From: kai <email@hidden>
- Date: Sat, 19 Feb 2005 04:32:00 +0000
On Thu, 17 Feb 2005 18:37:54 -0500, August Trometer <email@hidden>
wrote:
I'm trying to import a batch of photos from a folder to iPhoto. I've
gotten iPhoto to accept the photo import with no problem. However, I
would like to be able to return the ID of the imported photo.
Is there any way to do this?
And again, on Fri, 18 Feb 2005 08:04:34 -0500:
Actually I was hoping to get the ID of each photo as it's imported. By
using the "photos of last import (or rolls) album" I run the risk that
another photo might get imported at the same time and I end up
referring to the wrong photo.
I may end up doing this anyway, if I can't figure out how to get the ID
in response to the import.
One way would be to compare a pre-import list of photos against a
post-import one. It doesn't seem currently possible to get a list
satisfying a condition (i.e. a 'whose' filter), so I guess you'll have
to loop through the latest list.
Since you didn't post any code, it's not possible to adapt your
approach to offer you a more relevant example - but this might give you
a general idea:
----------------------------
property dfltAlbum : {}
to chooseAlbum(l)
tell (choose from list l with prompt "Choose a target album:" default
items dfltAlbum)
if it is false then error number -128
set dfltAlbum to it
item 1
end tell
end chooseAlbum
on latestImport(l, r)
repeat with p in r
if p is not in l then return p mod (8 ^ 8)
end repeat
end latestImport
tell application "iPhoto"
set currAlbum to album (my chooseAlbum(name of albums))
tell me to set currFile to choose file of type {"JPEG", "TIFF", "GIFf"}
tell currAlbum
set prevList to id of photos
import from currFile to it
set currID to my latestImport(prevList, id of photos)
end tell
end tell
-- do something with currID
----------------------------
The curious, 'p mod (8 ^ 8)' statement in the 'latestImport' handler is
a workaround for what appears to be a bug, which I recall noticing in
previous releases - as well as in the version I'm currently using
(4.0.3). Put simply, the ID of a recently imported photo looks
something like 4.29496745E+9. However, once iTunes is subsequently quit
and relaunched, the ID value returned for the same photo would be 154.0.
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden