| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Followme::JpegData; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
613
|
use 5.008005; |
|
|
3
|
|
|
|
|
20
|
|
|
4
|
3
|
|
|
3
|
|
19
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
99
|
|
|
5
|
3
|
|
|
3
|
|
20
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
84
|
|
|
6
|
3
|
|
|
3
|
|
15
|
use integer; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
17
|
|
|
7
|
3
|
|
|
3
|
|
124
|
use lib '../..'; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
26
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
432
|
use base qw(App::Followme::FileData); |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
662
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
760
|
use Image::Size; |
|
|
3
|
|
|
|
|
4936
|
|
|
|
3
|
|
|
|
|
246
|
|
|
12
|
3
|
|
|
3
|
|
23
|
use File::Spec::Functions qw(abs2rel rel2abs splitdir catfile); |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
181
|
|
|
13
|
3
|
|
|
3
|
|
19
|
use App::Followme::FIO; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
1367
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = "2.01"; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
18
|
|
|
|
|
|
|
# Read the default parameter values |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub parameters { |
|
21
|
16
|
|
|
16
|
1
|
29
|
my ($self) = @_; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return ( |
|
24
|
16
|
|
|
|
|
57
|
extension => 'jpg', |
|
25
|
|
|
|
|
|
|
target_prefix => 'img', |
|
26
|
|
|
|
|
|
|
thumb_suffix => '-thumb', |
|
27
|
|
|
|
|
|
|
); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
31
|
|
|
|
|
|
|
# Look in the file for the data |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub fetch_from_file { |
|
34
|
19
|
|
|
19
|
0
|
1325
|
my ($self, $filename) = @_; |
|
35
|
|
|
|
|
|
|
|
|
36
|
19
|
100
|
|
|
|
363
|
return () unless -e $filename; |
|
37
|
12
|
100
|
|
|
|
753
|
return $self->SUPER::fetch_from_file($filename) if -T $filename; |
|
38
|
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
19
|
my %dimensions; |
|
40
|
5
|
|
|
|
|
30
|
($dimensions{width}, $dimensions{height}) = imgsize($filename); |
|
41
|
|
|
|
|
|
|
|
|
42
|
5
|
|
|
|
|
2111
|
return %dimensions; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
46
|
|
|
|
|
|
|
# Get the name of the thumb photo file |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub get_thumb_file { |
|
49
|
20
|
|
|
20
|
0
|
743
|
my ($self, $filename) = @_; |
|
50
|
|
|
|
|
|
|
|
|
51
|
20
|
|
|
|
|
64
|
my ($dir, $file) = fio_split_filename($filename); |
|
52
|
20
|
|
|
|
|
65
|
my ($root, $ext) = split(/\./, $file); |
|
53
|
20
|
|
|
|
|
55
|
$file = join('', $root, $self->{thumb_suffix}, '.', $ext); |
|
54
|
20
|
|
|
|
|
96
|
my $photoname = catfile($dir, $file); |
|
55
|
|
|
|
|
|
|
|
|
56
|
20
|
|
|
|
|
74
|
return [$photoname]; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
60
|
|
|
|
|
|
|
# Get a url from a filename |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get_url { |
|
63
|
20
|
|
|
20
|
0
|
39
|
my ($self, $filename) = @_; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
return $self->filename_to_url($self->{top_directory}, |
|
66
|
20
|
|
|
|
|
68
|
$filename); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
70
|
|
|
|
|
|
|
# Set up exclude |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub setup { |
|
73
|
4
|
|
|
4
|
1
|
11
|
my ($self) = @_; |
|
74
|
|
|
|
|
|
|
|
|
75
|
4
|
|
|
|
|
9
|
my $dir; |
|
76
|
4
|
|
|
|
|
18
|
my $thumb_files = $self->get_thumb_file("*.$self->{extension}"); |
|
77
|
4
|
|
|
|
|
23
|
($dir, $self->{exclude}) = fio_split_filename($thumb_files->[0]); |
|
78
|
|
|
|
|
|
|
|
|
79
|
4
|
|
|
|
|
15
|
return; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=pod |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=encoding utf-8 |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
App::Followme::JpegData - Read datafrom a jpeg file |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
use App::Followme::JpegData; |
|
95
|
|
|
|
|
|
|
my $data = App::Followme::JpegData->new(); |
|
96
|
|
|
|
|
|
|
my $html = App::Followme::Template->new('example.htm', $data); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This module extratcs metadata from a jpeg image and uses that metadata to |
|
101
|
|
|
|
|
|
|
build variables used in a template. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 METHODS |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
All data classes are first instantiated by calling new and the object |
|
106
|
|
|
|
|
|
|
created is passed to a template object. It calls the build method with an |
|
107
|
|
|
|
|
|
|
argument name to retrieve that data item, though for the sake of |
|
108
|
|
|
|
|
|
|
efficiency, all the data are read from the file at once. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 VARIABLES |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=over 4 |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item @thumb_file |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
The name of the thumb file for a photo. Even though this is a single file, it |
|
117
|
|
|
|
|
|
|
is returned as a hash and thus must be used in a for statement. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item $height |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
The height of the photo |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item $width |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
The width of the photo |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
The following fields in the configuration file are used in this class and every |
|
132
|
|
|
|
|
|
|
class based on it: |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over 4 |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item extension |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The extension used by jpeg files. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item target_prefix |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
The prefix used to build the target names. The default value is 'img'. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item thumb_suffix |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
The suffix added to the root of the photo filename to build the thumb photo |
|
147
|
|
|
|
|
|
|
filename. The default value is '-thumb'. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=back |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 LICENSE |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Copyright (C) Bernie Simon. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
156
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 AUTHOR |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Bernie Simon E<lt>bernie.simon@gmail.comE<gt> |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |