| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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]
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]
| |||||||||||||||||||||||||||||
| 56 | 1 | ▶ | return $x && $y | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$x and $y
MC/DC0%0/2
$x and $y
$x
$y
Truth table33%1/3
A and B
A= $xB= $y
| |||||||||||||||||||||||||||||
| 57 | ? "$title ($type ${x}x${y})" | ||||||||||||||||||||||||||||
| 58 | : "$title ($type)"; | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 3 | 1; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||||||||