| 1 | package Khonsu::Image; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use parent 'Khonsu::Ra'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | sub attributes { | ||||||||||||||||||||||||||||
| 6 | 2 | ▶ | my $a = shift; | ||||||||||||||||||||||||||
|
Subroutine
attributes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 7 | return ( | ||||||||||||||||||||||||||||
| 8 | image => {$a->RW}, | ||||||||||||||||||||||||||||
| 9 | mime => {$a->RW, $a->STR}, | ||||||||||||||||||||||||||||
| 10 | valid_mime => {$a->RW, $a->HR, default => sub {{ | ||||||||||||||||||||||||||||
| 11 | 2 | ▶ | jpeg => 'image_jpeg', | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | tiff => 'image_tiff', | ||||||||||||||||||||||||||||
| 13 | pnm => 'image_pnm', | ||||||||||||||||||||||||||||
| 14 | png => 'image_png', | ||||||||||||||||||||||||||||
| 15 | gif => 'image_gif' | ||||||||||||||||||||||||||||
| 16 | }}}, | ||||||||||||||||||||||||||||
| 17 | 2 | $a->POINTS | |||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | sub add { | ||||||||||||||||||||||||||||
| 22 | 4 | ▶ | my ($self, $file, %attributes) = @_; | ||||||||||||||||||||||||||
|
Subroutine
add: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 4 | $self->set_attributes(%attributes); | |||||||||||||||||||||||||||
| 24 | 4 | my $type = $self->_identify_type(); | |||||||||||||||||||||||||||
| 25 | 4 | my $image = $file->pdf->$type($self->image); | |||||||||||||||||||||||||||
| 26 | 4 | my %points = $self->get_points(); | |||||||||||||||||||||||||||
| 27 | 4 | my $photo = $file->page->current->gfx; | |||||||||||||||||||||||||||
| 28 | $photo->image( | ||||||||||||||||||||||||||||
| 29 | $image, | ||||||||||||||||||||||||||||
| 30 | $points{x}, $points{y}, $points{w}, $points{h} | ||||||||||||||||||||||||||||
| 31 | 4 | ); | |||||||||||||||||||||||||||
| 32 | 4 | return $file; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | sub _identify_type { | ||||||||||||||||||||||||||||
| 36 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_identify_type: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||
| 37 | 4 | ▶ | if (!$self->mime && !ref $self->image) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->mime or ref $self->image
MC/DC50%1/2
$self->mime or ref $self->image
$self->mime
ref $self->image
Truth table66%2/3
A or B
A= $self->mimeB= ref $self->image
| |||||||||||||||||||||||||||||
| 38 | 2 | my $reg = sprintf '\.(%s)$', join ("|", keys %{$self->valid_mime}); | |||||||||||||||||||||||||||
| 39 | 2 | $self->image =~ m/$reg/; | |||||||||||||||||||||||||||
| 40 | 2 | my $m = $1; | |||||||||||||||||||||||||||
| 41 | 2 | ▶ | $self->mime($m || 'png'); | ||||||||||||||||||||||||||
|
Condition50%1/2
$m || 'png'
MC/DC0%0/1
$m || 'png'
$m
Truth table50%1/2
A
A= $m
| |||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 4 | return $self->valid_mime->{$self->mime}; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 3 | 1; | |||||||||||||||||||||||||||