| MP3-Tag documentation | Contained in the MP3-Tag distribution. |
MP3::Tag::ImageSize - extract size info from image files via Image::Size.
my $db = MP3::Tag::ImageSize->new($filename); # Name of multimedia file
see MP3::Tag
MP3::Tag::ImageSize is designed to be called from the MP3::Tag module.
It implements width(), height() and mime_type() methods (sizes in pixels).
They return undef if Image::Size is not available, or does not return valid data.
| MP3-Tag documentation | Contained in the MP3-Tag distribution. |
package MP3::Tag::ImageSize; use strict; use File::Basename; #use File::Spec; use vars qw /$VERSION @ISA/; $VERSION="0.01"; @ISA = 'MP3::Tag::__hasparent';
# Constructor sub new_with_parent { my ($class, $f, $p, $e, %seen, @cue) = (shift, shift, shift); $f = $f->filename if ref $f; bless [$f], $class; } sub new { my ($class, $f) = (shift, shift); $class->new_with_parent($f, undef, @_); } # Destructor sub DESTROY {} my @fields = qw( 0 0 width height img_type mime_type ); for my $elt ( 2, 3, 4, 5 ) { # i_bitdepth my $r = sub (;$) { my $self = shift; unless ($self->[1]) { my ($w, $h, $t) = eval { require Image::Size; Image::Size::imgsize($self->[0]) }; defined $w or @$self[1..4] = (1,undef,undef,undef), return; my $tt = "image/\L$t"; @$self[1..5] = (1, $w, $h, $t, $tt); } return $self->[$elt]; }; no strict 'refs'; *{$fields[$elt]} = $r; } for my $elt ( qw( title track artist album year genre comment ) ) { no strict 'refs'; *$elt = sub (;$) { return }; } 1;