line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Image::Processor;
|
2
|
1
|
|
|
1
|
|
12496
|
use strict;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
99
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
|
|
936
|
use base ( 'Image::Processor::Base',
|
5
|
|
|
|
|
|
|
'Image::Processor::CD',
|
6
|
|
|
|
|
|
|
'Image::Processor::Interface::Console',
|
7
|
|
|
|
|
|
|
'Image::Processor::Store::File',
|
8
|
|
|
|
|
|
|
'Image::Processor::Mail::GetImages',
|
9
|
|
|
|
|
|
|
'Image::Processor::Create::HTML'
|
10
|
|
|
|
|
|
|
#'Image::Processor::Interface::Web',
|
11
|
1
|
|
|
1
|
|
6
|
);
|
|
1
|
|
|
|
|
4
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use vars ('$VERSION');
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Image::Magick;
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$VERSION = '0.6';
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub process {
|
20
|
|
|
|
|
|
|
my ($self) = @_;
|
21
|
|
|
|
|
|
|
if ($self->{'orderid'} eq '' && $self->cdrom ne '') {
|
22
|
|
|
|
|
|
|
$self->read_info_cd();
|
23
|
|
|
|
|
|
|
}
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$self->determine_source();
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# exit conditions
|
28
|
|
|
|
|
|
|
# - no output_directory
|
29
|
|
|
|
|
|
|
$self->graceful_exit(
|
30
|
|
|
|
|
|
|
"You have not set the 'output_directory'")
|
31
|
|
|
|
|
|
|
if !$self->output_directory();
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# - no source_directory
|
34
|
|
|
|
|
|
|
$self->graceful_exit(
|
35
|
|
|
|
|
|
|
"You have not set the 'source_directory'")
|
36
|
|
|
|
|
|
|
if !$self->source_directory();
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$self->get_image_list();
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# - no list of images
|
41
|
|
|
|
|
|
|
$self->graceful_exit(
|
42
|
|
|
|
|
|
|
qq~
|
43
|
|
|
|
|
|
|
I have no list of images,
|
44
|
|
|
|
|
|
|
double check the 'source_directory' or 'drive'.
|
45
|
|
|
|
|
|
|
I had ~ . $self->cdrom . qq~ as a possible location~)
|
46
|
|
|
|
|
|
|
if !$self->image_list();
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# - no modify_array
|
49
|
|
|
|
|
|
|
$self->graceful_exit(
|
50
|
|
|
|
|
|
|
qq~
|
51
|
|
|
|
|
|
|
You didn't specify how I should process the images, I need
|
52
|
|
|
|
|
|
|
an array ref that looks something like this:
|
53
|
|
|
|
|
|
|
[
|
54
|
|
|
|
|
|
|
{ suffix => 'thumb_', percent => '15' },
|
55
|
|
|
|
|
|
|
{ suffix => 'med_', percent => '50' },
|
56
|
|
|
|
|
|
|
]
|
57
|
|
|
|
|
|
|
pass as an argument into the 'modify_array' method~ )
|
58
|
|
|
|
|
|
|
if !$self->modify_array() || ref($self->modify_array()) ne 'ARRAY';
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $dir = $self->output_directory;
|
63
|
|
|
|
|
|
|
$dir .= "/CD_" . $self->{'orderid'} if $self->cdrom;
|
64
|
|
|
|
|
|
|
$self->output_directory($dir);
|
65
|
|
|
|
|
|
|
print "Working on output for " , $self->output_directory() , "\n";
|
66
|
|
|
|
|
|
|
# create a directory for storage
|
67
|
|
|
|
|
|
|
$self->prompt_to_verify_directory_creation($dir);
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# change to chdir for saving information
|
70
|
|
|
|
|
|
|
chdir($self->output_directory);
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$self->create_path($dir);
|
74
|
|
|
|
|
|
|
#foreach (@{ $self->image_list() }) {
|
75
|
|
|
|
|
|
|
# print "Copying $_\n";
|
76
|
|
|
|
|
|
|
# copy("$_","$dir/$_");
|
77
|
|
|
|
|
|
|
#}
|
78
|
|
|
|
|
|
|
#$self->create_index_html();
|
79
|
|
|
|
|
|
|
#$self->create_all_full_size();
|
80
|
|
|
|
|
|
|
#$self->create_all_medium_images();
|
81
|
|
|
|
|
|
|
#$self->create_all_thumbnail();
|
82
|
|
|
|
|
|
|
$self->make_various_sizes( $self->modify_array() );
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
print "A total of " . @{$self->image_list()} . " images were processed\n";
|
85
|
|
|
|
|
|
|
}
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub list_images {
|
88
|
|
|
|
|
|
|
my ($self,$set) = @_;
|
89
|
|
|
|
|
|
|
return $self->{'list_images'} if !$set;
|
90
|
|
|
|
|
|
|
$self->{'list_images'} = $set;
|
91
|
|
|
|
|
|
|
}
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub modify_array {
|
94
|
|
|
|
|
|
|
my ($self,$set) = @_;
|
95
|
|
|
|
|
|
|
return $self->{'modify_array'} if !$set;
|
96
|
|
|
|
|
|
|
$self->{'modify_array'} = $set;
|
97
|
|
|
|
|
|
|
}
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub copy_images {
|
100
|
|
|
|
|
|
|
my ($self,$set) = @_;
|
101
|
|
|
|
|
|
|
return $self->{'copy_images'} if !$set;
|
102
|
|
|
|
|
|
|
$self->{'copy_images'} = $set;
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub resize_image {
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my ($self,$file) = @_;
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my($image, $x);
|
110
|
|
|
|
|
|
|
print "Creating image " . $self->percent . "% the size of $file\n";
|
111
|
|
|
|
|
|
|
$image = Image::Magick->new;
|
112
|
|
|
|
|
|
|
$x = $image->Read($self->source_directory . "/$file");
|
113
|
|
|
|
|
|
|
warn "$x" if "$x";
|
114
|
|
|
|
|
|
|
$x = $image->Resize('geometry' => $self->percent ."%" );
|
115
|
|
|
|
|
|
|
warn "$x" if "$x";
|
116
|
|
|
|
|
|
|
my $suffix = $self->suffix();
|
117
|
|
|
|
|
|
|
$file =~ s/(\.\w\w\w)/$suffix$1/;
|
118
|
|
|
|
|
|
|
$x = $image->Write($self->output_directory . "/" . "$file");
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
warn $x if $x;
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
}
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub make_various_sizes {
|
125
|
|
|
|
|
|
|
my ($self,$size_list) = @_;
|
126
|
|
|
|
|
|
|
=pod
|
127
|
|
|
|
|
|
|
# size list example
|
128
|
|
|
|
|
|
|
$size_list = [
|
129
|
|
|
|
|
|
|
{ suffix => 'small_', percent => '15' },
|
130
|
|
|
|
|
|
|
{ suffix => 'medium_', percent => '50' },
|
131
|
|
|
|
|
|
|
];
|
132
|
|
|
|
|
|
|
=cut
|
133
|
|
|
|
|
|
|
foreach my $size (@{$size_list}) {
|
134
|
|
|
|
|
|
|
$self->suffix( $size->{'suffix'} );
|
135
|
|
|
|
|
|
|
$self->percent( $size->{'percent'} );
|
136
|
|
|
|
|
|
|
$self->resize_images();
|
137
|
|
|
|
|
|
|
}
|
138
|
|
|
|
|
|
|
}
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub resize_images {
|
141
|
|
|
|
|
|
|
my ($self) = @_;
|
142
|
|
|
|
|
|
|
foreach my $file (@{ $self->image_list() }) {
|
143
|
|
|
|
|
|
|
$self->resize_image($file);
|
144
|
|
|
|
|
|
|
}
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
}
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub suffix {
|
149
|
|
|
|
|
|
|
my ($self,$set) = @_;
|
150
|
|
|
|
|
|
|
return $self->{'suffix'} if !$set;
|
151
|
|
|
|
|
|
|
if ($set =~ /none/i) { $self->{'suffix'} = ''; return }
|
152
|
|
|
|
|
|
|
$self->{'suffix'} = $set;
|
153
|
|
|
|
|
|
|
}
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub percent {
|
157
|
|
|
|
|
|
|
my ($self,$set) = @_;
|
158
|
|
|
|
|
|
|
return $self->{'percent'} if !$set;
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
$self->{'percent'} = $set;
|
161
|
|
|
|
|
|
|
}
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1;
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
__END__
|