#!/bin/sh convert -compress none -resize 66x23 - pgm:- | perl -e ' <> eq "P2\n" or die "ascii pgm input required\n"; <>; <>; # ignore depth, dimensions my @ch = split //, " .oO@"; while (<>) { print $ch[ $_ * @ch >> 8 ] for /\d+/g; print $/; } '