Next | Trivial Utilities | 136 |
for (0..1) { run("djpeg $ARGV[$_] > $pnm[$_]"); my $info = run("pnmfile $pnm[$_]"); $size[$_] = [$info =~ /(\d+) by (\d+)/]; # print "Size of $pnm[$_]: @{$size[$_]}\n"; }
Notice run in scalar context to gather the output of pnmfile
$info =~ /(\d+) by (\d+)/ returns a list of two numbers
Then [...] makes an array of these
This gathers the sizes of the two images
$size[x][0] is the width of image x
$size[x][1] is the height of image x
We need these because we need to make the images be the same size
Otherwise we can't subtract them
Next | Menu | Copyright © 2012 M. J. Dominus |