#! /usr/local/bin/perl

$cmd = "imginfo $ARGV[0]";

open( fp, "$cmd |" ) || die "Failed exec for $cmd\n";

while ( <fp> ) {
  if ( /Min\/Max/ ) {
    ( $tag, $min, $sep, $max ) = split( /\s+/ );
    $cmd = "cscale $ARGV[0] enhanced/$ARGV[0] $max $max $max -d";
    print "$cmd\n";
    `$cmd`;
    last;
  }
}

close fp;
