| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Khonsu::Image; |
|
2
|
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
32
|
use parent 'Khonsu::Ra'; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
29
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub attributes { |
|
6
|
4
|
|
|
4
|
0
|
11
|
my $a = shift; |
|
7
|
|
|
|
|
|
|
return ( |
|
8
|
|
|
|
|
|
|
image => {$a->RW}, |
|
9
|
|
|
|
|
|
|
mime => {$a->RW, $a->STR}, |
|
10
|
|
|
|
|
|
|
valid_mime => {$a->RW, $a->HR, default => sub {{ |
|
11
|
4
|
|
|
4
|
|
40
|
jpeg => 'image_jpeg', |
|
12
|
|
|
|
|
|
|
tiff => 'image_tiff', |
|
13
|
|
|
|
|
|
|
pnm => 'image_pnm', |
|
14
|
|
|
|
|
|
|
png => 'image_png', |
|
15
|
|
|
|
|
|
|
gif => 'image_gif' |
|
16
|
|
|
|
|
|
|
}}}, |
|
17
|
4
|
|
|
|
|
134
|
$a->POINTS |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub add { |
|
22
|
8
|
|
|
8
|
0
|
49
|
my ($self, $file, %attributes) = @_; |
|
23
|
8
|
100
|
|
|
|
43
|
if (!$attributes{x}) { |
|
24
|
2
|
|
|
|
|
12
|
$attributes{x} = $file->page->x; |
|
25
|
2
|
|
|
|
|
14
|
$attributes{y} = $file->page->y; |
|
26
|
2
|
|
33
|
|
|
13
|
$attributes{h} = $attributes{h} || $file->page->remaining_height(); |
|
27
|
2
|
|
33
|
|
|
15
|
$attributes{w} = $attributes{w} || $file->page->width(); |
|
28
|
2
|
50
|
|
|
|
13
|
if ($attributes{y} + $attributes{h} > $file->page->h) { |
|
29
|
0
|
|
|
|
|
0
|
$file->page->next(); |
|
30
|
0
|
|
|
|
|
0
|
$attributes{x} = $file->page->x; |
|
31
|
0
|
|
|
|
|
0
|
$attributes{y} = $file->page->y; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
} |
|
34
|
8
|
|
|
|
|
65
|
$self->set_attributes(%attributes); |
|
35
|
8
|
|
|
|
|
57
|
my $type = $self->_identify_type(); |
|
36
|
8
|
|
|
|
|
48
|
my $image = $file->pdf->$type($self->image); |
|
37
|
8
|
|
|
|
|
208068514
|
my %points = $self->get_points(); |
|
38
|
8
|
|
|
|
|
87
|
my $photo = $file->page->current->gfx; |
|
39
|
8
|
100
|
66
|
|
|
3039
|
if ($attributes{align} && $attributes{align} eq 'center') { |
|
40
|
2
|
|
|
|
|
16
|
my $single = ($file->page->w - ($file->page->padding * (2 + ($file->page->columns - 1)))) / $file->page->columns; |
|
41
|
2
|
|
|
|
|
16
|
$points{x} = (($file->page->padding + $single) * ($file->page->column - 1)) + $file->page->padding + (($single - $points{w}) / 2); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
$photo->image( |
|
44
|
|
|
|
|
|
|
$image, |
|
45
|
|
|
|
|
|
|
$points{x}, $file->page->h - ($points{y} + $points{h}), $points{w}, $points{h} |
|
46
|
8
|
|
|
|
|
63
|
); |
|
47
|
8
|
|
|
|
|
4814
|
$file->page->y($points{y} + $points{h}); |
|
48
|
8
|
|
|
|
|
76
|
return $file; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _identify_type { |
|
52
|
8
|
|
|
8
|
|
21
|
my ($self) = @_; |
|
53
|
8
|
50
|
66
|
|
|
68
|
if (!$self->mime && !ref $self->image) { |
|
54
|
4
|
|
|
|
|
36
|
my $reg = sprintf '\.(%s)$', join ("|", keys %{$self->valid_mime}); |
|
|
4
|
|
|
|
|
31
|
|
|
55
|
4
|
|
|
|
|
46
|
$self->image =~ m/$reg/; |
|
56
|
4
|
|
|
|
|
22
|
my $m = $1; |
|
57
|
4
|
|
50
|
|
|
29
|
$self->mime($m || 'png'); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
8
|
|
|
|
|
46
|
return $self->valid_mime->{$self->mime}; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |