line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MP3::Tag::ImageSize; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
45
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
180
|
|
4
|
6
|
|
|
6
|
|
32
|
use File::Basename; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
346
|
|
5
|
|
|
|
|
|
|
#use File::Spec; |
6
|
6
|
|
|
6
|
|
32
|
use vars qw /$VERSION @ISA/; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
1923
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION="0.01"; |
9
|
|
|
|
|
|
|
@ISA = 'MP3::Tag::__hasparent'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=pod |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
MP3::Tag::ImageSize - extract size info from image files via L. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $db = MP3::Tag::ImageSize->new($filename); # Name of multimedia file |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
see L |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
MP3::Tag::ImageSize is designed to be called from the MP3::Tag module. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
It implements width(), height() and mime_type() methods (sizes in pixels). |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
They return C if C is not available, or does not return valid data. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SEE ALSO |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
L, L |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Constructor |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub new_with_parent { |
41
|
85
|
|
|
85
|
0
|
275
|
my ($class, $f, $p, $e, %seen, @cue) = (shift, shift, shift); |
42
|
85
|
50
|
|
|
|
370
|
$f = $f->filename if ref $f; |
43
|
85
|
|
|
|
|
313
|
bless [$f], $class; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub new { |
47
|
0
|
|
|
0
|
0
|
0
|
my ($class, $f) = (shift, shift); |
48
|
0
|
|
|
|
|
0
|
$class->new_with_parent($f, undef, @_); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Destructor |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
0
|
|
|
sub DESTROY {} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my @fields = qw( 0 0 width height img_type mime_type ); |
56
|
|
|
|
|
|
|
for my $elt ( 2, 3, 4, 5 ) { # i_bitdepth |
57
|
|
|
|
|
|
|
my $r = sub (;$) { |
58
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
59
|
0
|
0
|
|
|
|
0
|
unless ($self->[1]) { |
60
|
0
|
|
|
|
|
0
|
my ($w, $h, $t) = eval { require Image::Size; |
|
0
|
|
|
|
|
0
|
|
61
|
0
|
|
|
|
|
0
|
Image::Size::imgsize($self->[0]) }; |
62
|
0
|
0
|
|
|
|
0
|
defined $w or @$self[1..4] = (1,undef,undef,undef), return; |
63
|
0
|
|
|
|
|
0
|
my $tt = "image/\L$t"; |
64
|
0
|
|
|
|
|
0
|
@$self[1..5] = (1, $w, $h, $t, $tt); |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
0
|
return $self->[$elt]; |
67
|
|
|
|
|
|
|
}; |
68
|
6
|
|
|
6
|
|
46
|
no strict 'refs'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
444
|
|
69
|
|
|
|
|
|
|
*{$fields[$elt]} = $r; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
for my $elt ( qw( title track artist album year genre comment ) ) { |
73
|
6
|
|
|
6
|
|
39
|
no strict 'refs'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
404
|
|
74
|
116
|
|
|
116
|
|
304
|
*$elt = sub (;$) { return }; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |