I recently wanted to export photo albums from iPhoto 4, including name and comments. With Mac::Glue, this part works very well - thanks to Chris Nandor (a code snippet is appended at the end of this post).
Now I want to access the current iPhoto selections in a Perl script. I tried several things, but did not succeed in getting properties like the comment. The closest I could get was:
use Mac::Glue;
my $iPhoto = Mac::Glue->new('iPhoto');
my $sel = $iPhoto->prop("selection");
my $count = $sel->count('each' => 'item');foreach my $i ( 0.. $count) {
my $prop = $iPhoto->prop(comment => item => $i, $sel);defined $prop or die "prop not defined"; # this works well my $comment = $prop->get;
defined $comment or die "comment not defined"; # this does not :-( }
So, anyone knows what to do here?
Thanks Stephan
PS: here is the code snipper when using albums:
# [...]
my $album = $iPhoto->prop('current_album');
# [...]
my @propnames = qw/title comment date image_path/;
for my $i (1 .. $count) {
my $photo = $album->obj(photo => $i);
my %props;
$props{$_} = $photo->prop($_)->get for @propnames; print "$props{$_}\n" for @propnames;
print "------------------------\n";
}