elsif ($g == 255){ $idx = @master_ascii; }
should be
elsif ($g == 255){ $idx = $#master_ascii; }
which allows us to change
my $char = $master_ascii[$idx]; print defined $char ? $char : ' ';
to
print $master_ascii[$idx];
my @master_ascii = (qw(W M 0 @ N & ), ',', qw(' - . `), ' ');
can be simplified to
my @master_ascii = (qw(W M 0 @ N & , ' - . `), ' ');
Also,
$idx = int((scalar @master_ascii) * $g / 256);
can be simplified to
$idx = @master_ascii * $g / 256;
(Multiplication already imposes a scalar context, and there's an implied int around values used as array indexes.)
Update: It would be extra cool is you compressed the image vertically to preserve the aspect ratio.
In reply to Re^2: PNG to ASCII ?
by ikegami
in thread PNG to ASCII ?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |