perl script calling convert
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 9 Feb 2020 20:58:18 +0000 (21:58 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Sun, 9 Feb 2020 20:58:18 +0000 (21:58 +0100)
termimg

diff --git a/termimg b/termimg
index d17805f072ddc3925e1cf391c6cdebaa81216a15..4deee150e845031f965179380863084a65cab731 100755 (executable)
--- a/termimg
+++ b/termimg
@@ -1,12 +1,18 @@
-#!/bin/sh
-convert -compress none +distort SRT '0,0 1,.56 0' -thumbnail ${1:-66x23} - pgm:- |
-perl -e '
-<> eq "P2\n" or die "ascii pgm input required\n";
-<>; <>;  # ignore depth, dimensions
+#!/usr/bin/perl
+use 5.014;
+my ($file, $size) = @ARGV;
+
+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 (<>) {
+while (<$pgm>) {
        print $ch[ $_ * @ch >> 8 ] for /\d+/g;
        print $/;
 }
-'