4deee150e845031f965179380863084a65cab731
[minime.git] / termimg
1 #!/usr/bin/perl
2 use 5.014;
3 my ($file, $size) = @ARGV;
4
5 open my $pgm, '-|', convert => (
6         -compress => 'none',
7         '+distort' => SRT => '0,0 1,.56 0',
8         -thumbnail => $size || '66x23',
9         $file => 'pgm:-'
10 ) or die $!;
11 <$pgm> eq "P2\n" or die "ascii pgm input required\n";
12 <$pgm>; <$pgm>;  # ignore depth, dimensions
13
14 my @ch = split //, " .:coO@";
15 while (<$pgm>) {
16         print $ch[ $_ * @ch >> 8 ] for /\d+/g;
17         print $/;
18 }