sub get_metadata {
my $self = shift;
my $file = $_[0] || return 0;
use Image::ExifTool qw(:Public);
my $exifTool = new Image::ExifTool;
my $meta;
$meta->{info} = $exifTool->ExtractInfo($file);
my @extracttags = qw(Author Copyright MIMEType ImageWidth ImageHeigh
+t XResolution ISO Make ImageSize CreateDate
FileType Comment CompressionType AudioLayer AudioBitrate SampleRate C
+opyrightFlag AspectRatio VideoBitrate
CodecList ContentEncryption Compression FrameRate FrameCount Duration
+ copyright description title Artist Album
Year PlayCounter PublisherURL UserDefinedURL CommercialURL Model Foca
+lLength Lens Subject Producer ModifyDate
PageCount BackgroundColor URL Version -ID3v1:Author -ID3v1:Comment -
+ID3v1:Title -ID3v2_3:Album -ID3v2_3:Artist -ID3v2_3:Year);
$exifTool->Options(Duplicates => 0);
$meta->{info} = ImageInfo($file, \@extracttags);
sub clear_dupekeys { # clear out nasty keys on a nasty way so they a
+re xml compliant and not duplicate
my $self = shift;
my $tag = shift;
$tag =~ s/ \(1\)$//i;
my $dupetag = $tag;
$dupetag .= " (1)" if not substr($dupetag,length($dupetag)-4,4) eq
+ " (1)";
if ($meta->{info}->{$dupetag}) {
$meta->{info}->{$tag} = $meta->{info}->{$dupetag};
delete $meta->{info}->{$dupetag};
}
}
my $temphash = $meta->{info};
for my $keyref ( keys %$temphash ) {
$self->clear_dupekeys($keyref);
}
$meta->{type} = Image::ExifTool::GetFileType($file, 1);
no Image::ExifTool;
return $meta;
}
|