… | |
… | |
41 | eval { |
41 | eval { |
42 | open my $fh, "convert \Q$path.png\E -depth 8 rgb:- |" |
42 | open my $fh, "convert \Q$path.png\E -depth 8 rgb:- |" |
43 | or die "convert: $!"; |
43 | or die "convert: $!"; |
44 | binmode $fh; |
44 | binmode $fh; |
45 | |
45 | |
46 | binmode $fh; |
|
|
47 | $size * 3 == read $fh, my $data, $size * 3 |
46 | $size * 3 == read $fh, my $data, $size * 3 |
48 | or die "$path.png, expected $size rgb triplets: $!"; |
47 | or die "$path.png, expected $size rgb triplets: $!"; |
49 | |
48 | |
50 | $data =~ s{(...)}{ |
49 | cf::_quantise $data, [map "$_$plt{$_}", keys %plt]; |
51 | $plt{$1} or die "$path.png: color not in palette: #" . unpack "H*", $1 |
|
|
52 | }sge; |
|
|
53 | |
50 | |
54 | binmode STDOUT; |
51 | binmode STDOUT; |
55 | syswrite STDOUT, $data; |
52 | syswrite STDOUT, $data; |
56 | }; |
53 | }; |
57 | warn $@ if $@; |
54 | warn $@ if $@; |