From b637f6e61ec3f236de28a3d502f70ce7aacba84e Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Wed, 7 Feb 2007 23:59:21 +0000 Subject: [PATCH] Read tags from Exif/IPTC. Closes #2. git-svn-id: http://svn.simon-cozens.org/memories/trunk@10 041978f6-d955-411f-a9d7-1d8545c9c3c7 --- Memories/Photo.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Memories/Photo.pm b/Memories/Photo.pm index 4279dc9..98444a7 100644 --- a/Memories/Photo.pm +++ b/Memories/Photo.pm @@ -54,6 +54,7 @@ sub do_upload :Exported { } $photo->make_thumb; + $r->{params}{tags} ||= join " ", map { qq{"$_"} } $photo->tags_exif; $photo->add_tags($r->{params}{tags}); $photo->add_to_imageseek_library; Memories->zap_cache(); @@ -318,4 +319,19 @@ sub description { sub title_exif { shift->_grovel_metadata( 'Headline', 'Title'); } sub license { shift->_grovel_metadata( 'Rights Usage Terms', 'Usage Terms' ) } sub copyright { shift->_grovel_metadata( 'Rights', 'Copyright', 'Copyright Notice') } + +# This one's slightly different since we want everything we can get... +sub tags_exif { + my $self = shift; + my %md = map {%$_} values %{$self->exif_info}; + my %tags = + map { s/\s+/-/g; lc $_ => 1 } + map { split /\s*,\s*/, $md{$_}} + grep {$md{$_} and $md{$_} =~/[^ 0:]/} + (qw(Keywords Subject City State Location Country Province-State), + 'Transmission Reference', 'Intellectual Genre', + 'Country-Primary Location Name' + ); + return keys %tags; +} 1; -- 2.39.2