line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# mamgal - a program for creating static image galleries |
2
|
|
|
|
|
|
|
# Copyright 2007, 2008 Marcin Owsiany |
3
|
|
|
|
|
|
|
# See the README file for license information |
4
|
|
|
|
|
|
|
# The picture encapsulating class |
5
|
|
|
|
|
|
|
package App::MaMGal::Entry::Picture::Static; |
6
|
1
|
|
|
1
|
|
10132
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
29
|
|
7
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
8
|
1
|
|
|
1
|
|
6
|
use base 'App::MaMGal::Entry::Picture'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
98
|
|
9
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
100
|
|
10
|
1
|
|
|
1
|
|
443
|
use Image::Magick; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use POSIX; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub init |
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
my $self = shift; |
16
|
|
|
|
|
|
|
$self->SUPER::init(@_); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub refresh_scaled_pictures |
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
my $self = shift; |
22
|
|
|
|
|
|
|
return $self->refresh_miniatures([$self->medium_dir, 800, 600], [$self->thumbnails_dir, 200, 150]); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub image_info |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
my $self = shift; |
28
|
|
|
|
|
|
|
return $self->{image_info} if exists $self->{image_info}; |
29
|
|
|
|
|
|
|
croak 'image info factory not injected' unless defined $self->tools->{image_info_factory}; |
30
|
|
|
|
|
|
|
$self->{image_info} = eval { $self->tools->{image_info_factory}->read($self->{path_name}); }; |
31
|
|
|
|
|
|
|
$self->logger->log_message("Cannot retrieve image info: ".$@, $self->{path_name}) if $@; |
32
|
|
|
|
|
|
|
return $self->{image_info}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub description |
36
|
|
|
|
|
|
|
{ |
37
|
|
|
|
|
|
|
my $self = shift; |
38
|
|
|
|
|
|
|
my $i = $self->image_info or return; |
39
|
|
|
|
|
|
|
return $i->description; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub read_image |
43
|
|
|
|
|
|
|
{ |
44
|
|
|
|
|
|
|
my $self = shift; |
45
|
|
|
|
|
|
|
my $i = Image::Magick->new; |
46
|
|
|
|
|
|
|
my $r; |
47
|
|
|
|
|
|
|
$r = $i->Read($self->{path_name}) and App::MaMGal::SystemException->throw(message => '%s: reading failed: %s', objects => [$self->{path_name}, $r]); |
48
|
|
|
|
|
|
|
return $i; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub creation_time |
52
|
|
|
|
|
|
|
{ |
53
|
|
|
|
|
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
my $info = $self->image_info or return $self->SUPER::creation_time(@_); |
55
|
|
|
|
|
|
|
return $info->creation_time || $self->SUPER::creation_time(@_); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |