| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Image::ThumbHash; |
|
2
|
2
|
|
|
2
|
|
532507
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
141
|
|
|
3
|
2
|
|
|
2
|
|
39
|
use warnings qw(all FATAL uninitialized); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
209
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
13
|
use Carp qw(croak); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
124
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use Exporter 5.57 qw(import); |
|
|
2
|
|
|
|
|
47
|
|
|
|
2
|
|
|
|
|
183
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $_BACKEND = 'PP'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
2
|
|
|
|
|
669
|
use Image::ThumbHash::PP our @EXPORT_OK = qw( |
|
13
|
|
|
|
|
|
|
rgba_to_thumb_hash |
|
14
|
|
|
|
|
|
|
rgba_to_png |
|
15
|
|
|
|
|
|
|
rgba_to_data_url |
|
16
|
|
|
|
|
|
|
thumb_hash_to_rgba |
|
17
|
|
|
|
|
|
|
thumb_hash_to_average_rgba |
|
18
|
|
|
|
|
|
|
thumb_hash_to_approximate_aspect_ratio |
|
19
|
|
|
|
|
|
|
thumb_hash_to_data_url |
|
20
|
2
|
|
|
2
|
|
1216
|
); |
|
|
2
|
|
|
|
|
14
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
push our @EXPORT_OK, qw( |
|
23
|
|
|
|
|
|
|
imager_to_rgba |
|
24
|
|
|
|
|
|
|
imager_to_thumb_hash |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub imager_to_rgba { |
|
28
|
0
|
|
|
0
|
1
|
|
my ($img) = @_; |
|
29
|
0
|
0
|
|
|
|
|
wantarray or croak "imager_to_rgba: must be called in list context"; |
|
30
|
0
|
|
|
|
|
|
$img = $img->to_rgb8; |
|
31
|
0
|
0
|
|
|
|
|
$img = $img->scale( |
|
32
|
|
|
|
|
|
|
xpixels => 100, |
|
33
|
|
|
|
|
|
|
ypixels => 100, |
|
34
|
|
|
|
|
|
|
type => 'min', |
|
35
|
|
|
|
|
|
|
qtype => 'mixing', |
|
36
|
|
|
|
|
|
|
) or croak "imager_to_rgba: cannot scale: " . $img->errstr; |
|
37
|
0
|
|
|
|
|
|
$img = $img->convert(preset => 'addalpha'); |
|
38
|
0
|
0
|
|
|
|
|
$img->write(type => 'raw', data => \my $data) |
|
39
|
|
|
|
|
|
|
or croak "imager_to_rgba: cannot write: " . $img->errstr; |
|
40
|
0
|
|
|
|
|
|
$img->getwidth, $img->getheight, $data |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub imager_to_thumb_hash { |
|
44
|
0
|
|
|
0
|
1
|
|
my ($img) = @_; |
|
45
|
0
|
|
|
|
|
|
rgba_to_thumb_hash imager_to_rgba $img |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1 |
|
49
|
|
|
|
|
|
|
__END__ |