line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Image; |
2
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
124800
|
use strict; |
|
12
|
|
|
|
|
87
|
|
|
12
|
|
|
|
|
351
|
|
4
|
12
|
|
|
12
|
|
90
|
use warnings; |
|
12
|
|
|
|
|
28
|
|
|
12
|
|
|
|
|
460
|
|
5
|
|
|
|
|
|
|
|
6
|
12
|
|
|
12
|
|
5679
|
use Mo qw(build is); |
|
12
|
|
|
|
|
6543
|
|
|
12
|
|
|
|
|
62
|
|
7
|
12
|
|
|
12
|
|
24455
|
use Mo::utils qw(check_code check_isa check_length check_number check_required); |
|
12
|
|
|
|
|
195693
|
|
|
12
|
|
|
|
|
218
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.03; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has author => ( |
12
|
|
|
|
|
|
|
is => 'ro', |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has comment => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has dt_created => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has height => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has id => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has size => ( |
32
|
|
|
|
|
|
|
is => 'ro', |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has url => ( |
36
|
|
|
|
|
|
|
is => 'ro', |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has url_cb => ( |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has width => ( |
44
|
|
|
|
|
|
|
is => 'ro', |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub BUILD { |
48
|
22
|
|
|
22
|
0
|
12873
|
my $self = shift; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Check author. |
51
|
22
|
|
|
|
|
106
|
check_length($self, 'author', 255); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Check comment. |
54
|
22
|
|
|
|
|
369
|
check_length($self, 'comment', 1000); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Check date created. |
57
|
21
|
|
|
|
|
230
|
check_isa($self, 'dt_created', 'DateTime'); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# Check height. |
60
|
21
|
|
|
|
|
239
|
check_number($self, 'height'); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Check id. |
63
|
21
|
|
|
|
|
214
|
check_number($self, 'id'); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Check size. |
66
|
21
|
|
|
|
|
221
|
check_number($self, 'size'); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Check URL. |
69
|
21
|
|
|
|
|
191
|
check_length($self, 'url', 255); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Check URL callback. |
72
|
20
|
|
|
|
|
236
|
check_code($self, 'url_cb'); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Check width. |
75
|
20
|
|
|
|
|
231
|
check_number($self, 'width'); |
76
|
|
|
|
|
|
|
|
77
|
20
|
|
|
|
|
162
|
return; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=pod |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=encoding utf8 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Data::Image - Data object for image. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SYNOPSIS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
use Data::Image; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $obj = Data::Image->new(%params); |
97
|
|
|
|
|
|
|
my $author = $obj->author; |
98
|
|
|
|
|
|
|
my $comment = $obj->comment; |
99
|
|
|
|
|
|
|
my $dt_created = $obj->dt_created; |
100
|
|
|
|
|
|
|
my $height = $obj->height; |
101
|
|
|
|
|
|
|
my $id = $obj->id; |
102
|
|
|
|
|
|
|
my $size = $obj->size; |
103
|
|
|
|
|
|
|
my $url = $obj->url; |
104
|
|
|
|
|
|
|
my $url_cb = $obj->url_cb; |
105
|
|
|
|
|
|
|
my $width = $obj->width; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 METHODS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 C<new> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my $obj = Data::Image->new(%params); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Constructor. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Returns instance of object. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over 8 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * C<author> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Image author. |
122
|
|
|
|
|
|
|
It's optional. |
123
|
|
|
|
|
|
|
Default value is undef. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * C<comment> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Image comment. |
128
|
|
|
|
|
|
|
It's optional. |
129
|
|
|
|
|
|
|
Default value is undef. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * C<dt_created> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Date and time the image was created. |
134
|
|
|
|
|
|
|
Value must be L<DateTime> object. |
135
|
|
|
|
|
|
|
It's optional. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * C<height> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Image height. |
140
|
|
|
|
|
|
|
It's optional. |
141
|
|
|
|
|
|
|
Default value is undef. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * C<id> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Image id. |
146
|
|
|
|
|
|
|
It's optional. |
147
|
|
|
|
|
|
|
Default value is undef. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * C<size> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Image size. |
152
|
|
|
|
|
|
|
It's optional. |
153
|
|
|
|
|
|
|
Default value is undef. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * C<url> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
URL of image. |
158
|
|
|
|
|
|
|
It's optional. |
159
|
|
|
|
|
|
|
Default value is undef. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * C<url_cb> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
URL callback. To get URL from code. |
164
|
|
|
|
|
|
|
It's optional. |
165
|
|
|
|
|
|
|
Default value is undef. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * C<width> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Image width. |
170
|
|
|
|
|
|
|
It's optional. |
171
|
|
|
|
|
|
|
Default value is undef. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=back |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 C<author> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
my $author = $obj->author; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Get image author. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Returns string. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 C<comment> |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
my $comment = $obj->comment; |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Get image comment. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Returns string. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 C<dt_created> |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
my $dt_created = $obj->dt_created; |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Get date and time the image was created. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Returns L<DateTime> object. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head2 C<height> |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
my $height = $obj->height; |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Get image height. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Returns number. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head2 C<id> |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
my $id = $obj->id; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Get image id. |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Returns number. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head2 C<size> |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
my $size = $obj->size; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Get image size. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Returns number. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 C<url> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
my $url = $obj->url; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Get URL of image. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Returns string. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head2 C<url_cb> |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
my $url_cb = $obj->url_cb; |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Get URL callback. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Returns code. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head2 C<width> |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
my $width = $obj->width; |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Get image width. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Returns number. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 ERRORS |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
new(): |
250
|
|
|
|
|
|
|
From Mo::utils: |
251
|
|
|
|
|
|
|
Parameter 'author' has length greater than '255'. |
252
|
|
|
|
|
|
|
Value: %s |
253
|
|
|
|
|
|
|
Parameter 'comment' has length greater than '1000'. |
254
|
|
|
|
|
|
|
Value: %s |
255
|
|
|
|
|
|
|
Parameter 'dt_created' must be a 'DateTime' object. |
256
|
|
|
|
|
|
|
Value: %s |
257
|
|
|
|
|
|
|
Reference: %s |
258
|
|
|
|
|
|
|
Parameter 'height' must a number. |
259
|
|
|
|
|
|
|
Value: %s |
260
|
|
|
|
|
|
|
Parameter 'id' must a number. |
261
|
|
|
|
|
|
|
Value: %s |
262
|
|
|
|
|
|
|
Parameter 'size' must a number. |
263
|
|
|
|
|
|
|
Value: %s |
264
|
|
|
|
|
|
|
Parameter 'url' has length greater than '255'. |
265
|
|
|
|
|
|
|
Value: %s |
266
|
|
|
|
|
|
|
Parameter 'url_cb' must be a code. |
267
|
|
|
|
|
|
|
Value: %s |
268
|
|
|
|
|
|
|
Parameter 'width' must a number. |
269
|
|
|
|
|
|
|
Value: %s |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head1 EXAMPLE |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=for comment filename=create_and_print_image.pl |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
use strict; |
276
|
|
|
|
|
|
|
use warnings; |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
use Data::Image; |
279
|
|
|
|
|
|
|
use DateTime; |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
my $obj = Data::Image->new( |
282
|
|
|
|
|
|
|
'author' => 'Zuzana Zonova', |
283
|
|
|
|
|
|
|
'comment' => 'Michal from Czechia', |
284
|
|
|
|
|
|
|
'dt_created' => DateTime->new( |
285
|
|
|
|
|
|
|
'day' => 1, |
286
|
|
|
|
|
|
|
'month' => 1, |
287
|
|
|
|
|
|
|
'year' => 2022, |
288
|
|
|
|
|
|
|
), |
289
|
|
|
|
|
|
|
'height' => 2730, |
290
|
|
|
|
|
|
|
'size' => 1040304, |
291
|
|
|
|
|
|
|
'url' => 'https://upload.wikimedia.org/wikipedia/commons/a/a4/Michal_from_Czechia.jpg', |
292
|
|
|
|
|
|
|
'width' => 4096, |
293
|
|
|
|
|
|
|
); |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
# Print out. |
296
|
|
|
|
|
|
|
print 'Author: '.$obj->author."\n"; |
297
|
|
|
|
|
|
|
print 'Comment: '.$obj->comment."\n"; |
298
|
|
|
|
|
|
|
print 'Height: '.$obj->height."\n"; |
299
|
|
|
|
|
|
|
print 'Size: '.$obj->size."\n"; |
300
|
|
|
|
|
|
|
print 'URL: '.$obj->url."\n"; |
301
|
|
|
|
|
|
|
print 'Width: '.$obj->width."\n"; |
302
|
|
|
|
|
|
|
print 'Date and time the image was created: '.$obj->dt_created."\n"; |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
# Output: |
305
|
|
|
|
|
|
|
# Author: Zuzana Zonova |
306
|
|
|
|
|
|
|
# Comment: Michal from Czechia |
307
|
|
|
|
|
|
|
# Height: 2730 |
308
|
|
|
|
|
|
|
# Size: 1040304 |
309
|
|
|
|
|
|
|
# URL: https://upload.wikimedia.org/wikipedia/commons/a/a4/Michal_from_Czechia.jpg |
310
|
|
|
|
|
|
|
# Width: 4096 |
311
|
|
|
|
|
|
|
# Date and time the photo was created: 2022-01-01T00:00:00 |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
L<Mo>, |
316
|
|
|
|
|
|
|
L<Mo::utils>. |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=head1 SEE ALSO |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
=over |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=item L<Data::Commons::Image> |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
Data object for Wikimedia Commons image. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=back |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=head1 REPOSITORY |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Data-Image> |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=head1 AUTHOR |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
L<http://skim.cz> |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
© 2022-2023 Michal Josef Špaček |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
BSD 2-Clause License |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
=head1 VERSION |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
0.03 |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
=cut |