| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package URI::Title::Image; |
|
2
|
|
|
|
|
|
|
$URI::Title::Image::VERSION = '1.904'; |
|
3
|
2
|
|
|
2
|
|
1327
|
use warnings; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
69
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
45
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1194
|
use Image::Size; |
|
|
2
|
|
|
|
|
9426
|
|
|
|
2
|
|
|
|
|
909
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub types {( |
|
9
|
2
|
|
|
2
|
0
|
10
|
'image/gif', |
|
10
|
|
|
|
|
|
|
'image/jpg', |
|
11
|
|
|
|
|
|
|
'image/jpeg', |
|
12
|
|
|
|
|
|
|
'image/png', |
|
13
|
|
|
|
|
|
|
'image/x-png', |
|
14
|
|
|
|
|
|
|
)} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub pnginfo { |
|
17
|
1
|
|
|
1
|
0
|
3
|
my ($data_ref) = @_; |
|
18
|
1
|
|
|
|
|
3
|
my ($x, $y, $title) = (0, 0, ''); |
|
19
|
1
|
50
|
|
|
|
3
|
if ( eval { require Image::ExifTool } ) { |
|
|
1
|
50
|
|
|
|
217
|
|
|
20
|
0
|
|
|
|
|
0
|
my $info = Image::ExifTool::ImageInfo($data_ref); |
|
21
|
0
|
|
|
|
|
0
|
($x, $y, $title) = ($info->{ImageWidth}, $info->{ImageHeight}, $info->{Title}); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
1
|
|
|
|
|
121
|
elsif( eval { require Image::PNG::Libpng } ) { |
|
24
|
0
|
|
|
|
|
0
|
my $png = Image::PNG::Libpng::read_from_scalar($$data_ref); |
|
25
|
0
|
|
|
|
|
0
|
$x = $png->get_image_width(); |
|
26
|
0
|
|
|
|
|
0
|
$y = $png->get_image_height(); |
|
27
|
0
|
|
|
|
|
0
|
my $text_chunks = $png->get_text(); |
|
28
|
0
|
|
|
|
|
0
|
for (@$text_chunks) { |
|
29
|
0
|
0
|
|
|
|
0
|
if ($_->{key} eq "Title") { |
|
30
|
0
|
|
|
|
|
0
|
$title = $_->{text}; |
|
31
|
0
|
|
|
|
|
0
|
last; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
else { |
|
36
|
1
|
|
|
|
|
9
|
($x, $y) = imgsize($data_ref); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
1
|
|
|
|
|
120
|
return ($x, $y, $title); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub title { |
|
42
|
1
|
|
|
1
|
0
|
4
|
my ($class, $url, $data, $type) = @_; |
|
43
|
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
7
|
$type =~ s!^[^/]*/!!; |
|
45
|
1
|
|
|
|
|
5
|
$type =~ s!^x-!!; |
|
46
|
1
|
|
|
|
|
2
|
my $title = ""; |
|
47
|
1
|
|
|
|
|
4
|
my $x = 0; |
|
48
|
1
|
|
|
|
|
1
|
my $y = 0; |
|
49
|
1
|
50
|
|
|
|
6
|
if ( $type =~ /png/ ) { |
|
50
|
1
|
|
|
|
|
6
|
($x, $y, $title) = pnginfo(\$data); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
else { |
|
53
|
0
|
|
|
|
|
0
|
($x, $y) = imgsize(\$data); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
1
|
|
33
|
|
|
13
|
$title ||= ( split m{/}, $url )[-1]; |
|
56
|
1
|
50
|
33
|
|
|
20
|
return $x && $y |
|
57
|
|
|
|
|
|
|
? "$title ($type ${x}x${y})" |
|
58
|
|
|
|
|
|
|
: "$title ($type)"; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |