diff --git a/src/filters/rclimg b/src/filters/rclimg new file mode 100755 index 00000000..0edd51c1 --- /dev/null +++ b/src/filters/rclimg @@ -0,0 +1,75 @@ +#! /usr/bin/perl -w + + + +# +# maps image file tags to xapian tags +# +$tagMap = { + 'subject' => 'subject', + 'title' => 'title', + 'headline' => 'title', + 'caption' => 'caption', + 'caption-abstract' => 'caption', + 'author' => 'author', + 'creator' => 'creator', + 'from' => 'from', + 'keywords' => 'keywords', + 'keyword' => 'keyword', + 'tag' => 'tag', +}; + +# set to non-zero if tags which map to xapian tags are to output +# in the body as well as the header +# +$headAndBody = 0; + +# xapianTag +# returns a xapian tag to be used for this tag +# +sub xapianTag { + my $imgtag = shift; + while ( ( $tagre, $xapiantag) = each %{$tagMap} ) { + return $xapiantag if $imgtag =~ /$tagre/i; + } + return undef; +} + +# +# start here +# +use Image::ExifTool qw(:Public); + +$imageFile = shift; +$imageFile = '-' if $imageFile eq ''; +unless ( open(IMGF, $imageFile) ) { + print STDERR "$0: can't open file $imageFile\n"; + exit(1); # file doesn't exist or can't be read +} +$info = ImageInfo(\*IMGF); +die unless $info; +$fields = []; +$other = []; +$titleHtmlTag = ""; +foreach $tagname ( sort keys %{$info} ) { + $xapiantag = xapianTag($tagname); + if (defined $xapiantag ) { + push @{$fields}, [ $xapiantag, $info->{$tagname} ]; + $titleHtmlTag = "