X-Git-Url: http://git.shiar.nl/minime.git/blobdiff_plain/87f39256460859762af1985123ad86c1895c8726..c35b75ed17d73348ff6ea8a7403f39d459d6f5c9:/termimg?ds=sidebyside diff --git a/termimg b/termimg index 2545c9b..4deee15 100755 --- a/termimg +++ b/termimg @@ -1,10 +1,18 @@ -#!/bin/sh -convert -compress none -resize 66x23 - pgm:- | -perl -nE ' -$_ eq "P2\n" or die "ascii pgm input required\n" if $. == 1; -next if $. <= 3; +#!/usr/bin/perl +use 5.014; +my ($file, $size) = @ARGV; -state @ch = split //, " .oO@"; -print $ch[ $_ / 256 * @ch ] for /\d+/g; -print $/; -' +open my $pgm, '-|', convert => ( + -compress => 'none', + '+distort' => SRT => '0,0 1,.56 0', + -thumbnail => $size || '66x23', + $file => 'pgm:-' +) or die $!; +<$pgm> eq "P2\n" or die "ascii pgm input required\n"; +<$pgm>; <$pgm>; # ignore depth, dimensions + +my @ch = split //, " .:coO@"; +while (<$pgm>) { + print $ch[ $_ * @ch >> 8 ] for /\d+/g; + print $/; +}