line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Orze::Drivers::Thumb; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1213
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
445
|
use Image::Thumbnail; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use File::Basename; |
8
|
|
|
|
|
|
|
use File::Copy::Recursive qw/fcopy/; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use base "Orze::Drivers"; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Orze::Drivers::Thumb - Create a page by copying an image and making a thumbnail of it |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Create a page by copying an image from the C directory to the |
19
|
|
|
|
|
|
|
C directory and creating a thumbnail with the same name prefixed |
20
|
|
|
|
|
|
|
by C. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
It takes care of the following attributes: |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=over |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item format |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
The format for the thumbnail. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item size |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
The size of the thumbnail. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=back |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 EXAMPLE |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
extension="pdf" |
40
|
|
|
|
|
|
|
format="png" |
41
|
|
|
|
|
|
|
size="200x300" |
42
|
|
|
|
|
|
|
driver="Thumb"> |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
This snippet of an xml project description copy the file |
46
|
|
|
|
|
|
|
C to C and a |
47
|
|
|
|
|
|
|
thumbnail of size 300x200 to the file C |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 SEE ALSO |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Lookt at L for the supported formats. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 METHODS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 process |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Do the real processing |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub process { |
62
|
|
|
|
|
|
|
my ($self) = @_; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $page = $self->{page}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $size = $page->att('size'); |
67
|
|
|
|
|
|
|
my $format = $page->att('format'); |
68
|
|
|
|
|
|
|
my $name = $page->att('name'); |
69
|
|
|
|
|
|
|
my $extension = $page->att('extension'); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my ($source, $target) = $self->paths($name, $extension); |
72
|
|
|
|
|
|
|
fcopy($source, $target); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my ($base, $directory, $suffix) = fileparse($name); |
75
|
|
|
|
|
|
|
my $output = $self->output($directory . "thumb_" . $base, $format); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $t = new Image::Thumbnail( |
78
|
|
|
|
|
|
|
size => $size, |
79
|
|
|
|
|
|
|
create => 1, |
80
|
|
|
|
|
|
|
input => $source, |
81
|
|
|
|
|
|
|
outputpath => $output, |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |