line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! perl |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
12
|
use v5.26; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
6
|
use Object::Pad; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
7
|
|
5
|
1
|
|
|
1
|
|
109
|
use utf8; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
38
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
123
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
class SVGPDF::Image :isa(SVGPDF::Element); |
9
|
|
|
|
|
|
|
|
10
|
0
|
|
|
0
|
0
|
|
method process () { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
|
my $atts = $self->atts; |
12
|
0
|
|
|
|
|
|
my $xo = $self->xo; |
13
|
0
|
0
|
|
|
|
|
return if $atts->{omit}; # for testing/debugging. |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my ( $x, $y, $w, $h, $link, $tf ) = |
16
|
|
|
|
|
|
|
$self->get_params( $atts, qw( x:H y:V width:H height:V href:! transform:s ) ); |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
0
|
|
|
|
$x ||= 0; $y ||= 0; |
|
0
|
|
0
|
|
|
|
|
19
|
0
|
|
0
|
|
|
|
$w ||= 0; $h ||= 0; |
|
0
|
|
0
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
0
|
0
|
0
|
|
|
|
unless ( $w && $h ) { |
22
|
0
|
|
|
|
|
|
$self->_dbg( $self->name, " x=$x y=$y w=$w h=$h **skipped**" ); |
23
|
0
|
|
|
|
|
|
return; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$self->_dbg( $self->name, " x=$x y=$y w=$w h=$h" ); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $img; |
29
|
0
|
0
|
0
|
|
|
|
if ( $link =~ m!^data:image/(png|jpe?g);(base64),(.*)$!s ) { |
|
|
0
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# In-line image asset. |
31
|
0
|
|
|
|
|
|
require MIME::Base64; |
32
|
0
|
|
|
|
|
|
require Image::Info; |
33
|
0
|
|
|
|
|
|
require IO::String; |
34
|
0
|
|
|
|
|
|
my $type = $1; |
35
|
0
|
|
|
|
|
|
my $enc = $2; |
36
|
0
|
|
|
|
|
|
my $data = MIME::Base64::decode($3); |
37
|
0
|
0
|
|
|
|
|
unless ( $enc eq "base64" ) { |
38
|
0
|
|
|
|
|
|
warn("SVG: Unhandled encoding in image: $enc\n"); |
39
|
0
|
|
|
|
|
|
$self->css_pop, return; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Get info. |
43
|
0
|
|
|
|
|
|
my $info = Image::Info::image_info(\$data); |
44
|
0
|
0
|
|
|
|
|
if ( $info->{error} ) { |
45
|
0
|
|
|
|
|
|
warn($info->{error}); |
46
|
0
|
|
|
|
|
|
$self->css_pop, return; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Make the image. Silence missing Image::PNG::Libpng warnings. |
50
|
0
|
|
|
|
|
|
$img = $self->root->pdf->image( IO::String->new($data), |
51
|
|
|
|
|
|
|
silent => 1 ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
elsif ( $link =~ m!^.+\.(png|jpe?g)$! && -s $link ) { |
54
|
|
|
|
|
|
|
# Make the image. Silence missing Image::PNG::Libpng warnings. |
55
|
0
|
|
|
|
|
|
$img = $self->root->pdf->image($link, silent => 1 ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else { |
58
|
0
|
|
0
|
|
|
|
warn("SVG: Unhandled or missing image link: ", |
59
|
|
|
|
|
|
|
"\"$link\""//"", "\n"); |
60
|
0
|
|
|
|
|
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$self->_dbg( "xo save" ); |
64
|
0
|
|
|
|
|
|
$xo->save; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Place the image. |
67
|
0
|
0
|
|
|
|
|
$self->set_transform($tf) if $tf; |
68
|
0
|
|
|
|
|
|
$xo->transform( translate => [ $x, $y+$h ] ); |
69
|
0
|
|
|
|
|
|
$xo->image( $img, 0, 0, $w, -$h ); |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
$self->_dbg( "xo restore" ); |
72
|
0
|
|
|
|
|
|
$xo->restore; |
73
|
0
|
|
|
|
|
|
$self->css_pop; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |