lib/URI/Title/Image.pm

filter: Statementstmt 72.5% 29 / 40 Branchbran 40.0% 4 / 10 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 3 totaltotal 59.4% 41 / 69 CC 9 SCAR 18.2
CC
9
Cov
62%
pnginfo
10.6
title
5.9
BEGIN
1.0
CRAP 6.2
« blib/lib/URI/Title/Image.pm ↑ Summary
1 package URI::Title::Image;
2 3 $URI::Title::Image::VERSION = '1.903';
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Image::Size;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub types {(
9 2 ▶ 'image/gif',
Subroutine types: called CC=1 SCAR=0.0
Pod undocumented
10 'image/jpg',
11 'image/jpeg',
12 'image/png',
13 'image/x-png',
14 )}
15  
16 sub pnginfo {
17 1 ▶ my ($data_ref) = @_;
Subroutine pnginfo: called CC=5 SCAR=23.6
Pod undocumented
18 1 my ($x, $y, $title) = (0, 0, '');
19 1 ▶ if ( eval { require Image::ExifTool } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (eval { do { require Image::ExifTool } }) { } 0 1 1
elsif (eval { do { require Image::PNG::Libpng } }) { } 0 1 1
20 0 my $info = Image::ExifTool::ImageInfo($data_ref);
21 0 ($x, $y, $title) = ($info->{ImageWidth}, $info->{ImageHeight}, $info->{Title});
22 }
23 1 elsif( eval { require Image::PNG::Libpng } ) {
24 0 my $png = Image::PNG::Libpng::read_from_scalar($$data_ref);
25 0 $x = $png->get_image_width();
26 0 $y = $png->get_image_height();
27 0 my $text_chunks = $png->get_text();
28 0 for (@$text_chunks) {
29 0 ▶ if ($_->{key} eq "Title") {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"key"} eq "Title") 0 0 0
30 0 $title = $_->{text};
31 0 last;
32 }
33 }
34 }
35 else {
36 1 ($x, $y) = imgsize($data_ref);
37 }
38 1 return ($x, $y, $title);
39 }
40  
41 sub title {
42 1 ▶ my ($class, $url, $data, $type) = @_;
Subroutine title: called CC=5 SCAR=17.8
Pod undocumented
43  
44 1 $type =~ s!^[^/]*/!!;
45 1 $type =~ s!^x-!!;
46 1 my $title = "";
47 1 my $x = 0;
48 1 my $y = 0;
49 1 ▶ if ( $type =~ /png/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /png/) { } 1 0 1
50 1 ($x, $y, $title) = pnginfo(\$data);
51 }
52 else {
53 0 ($x, $y) = imgsize(\$data);
54 }
55 1 ▶ $title ||= ( split m{/}, $url )[-1];
Condition33%1/3
$title ||= (split(m[/], $url, 0))[-1]
l!l&&r!l&&!r
010
MC/DC0%0/2
$title ||= (split(m[/], $url, 0))[-1]
$title (split(m[/], $url, 0))[-1]
Truth table33%1/3
A ||= B
A= $titleB= (split(m[/], $url, 0))[-1]
ABresult
1X1
011
000
56 1 ▶ return $x && $y
Branch: 1 branch
BranchTrueFalseTotal
$x && $y ? : 1 0 1
Condition33%1/3
$x and $y
!ll&&!rl&&r
001
MC/DC0%0/2
$x and $y
$x $y
Truth table33%1/3
A and B
A= $xB= $y
ABresult
0X0
100
111
57 ? "$title ($type ${x}x${y})"
58 : "$title ($type)";
59 }
60  
61 3 1;
62  
63 __END__
« blib/lib/URI/Title/Image.pm ↑ Summary