$ENV{'PATH'} = "C:\\Program Files\\imageMagick;" . $ENV{'PATH'}; # ... for my $file (@files) { $fileNumber++; my $newFile = "$largeDir\\$basename$fileNumber.JPG"; print "$fileNumber copying $file...\n"; copy("$originalDir\\$file", $newFile); open(INFO, "identify $newFile |"); my $info = ; close INFO; my ($width, $height) = ($1, $2) if ($info =~ /\s(\d+)x(\d+)\s/); my ($newWidth, $newHeight, $thumbWidth, $thumbHeight); if ($width == 1200 && $height == 1600) { ($newWidth, $newHeight) = (600, 800); ($thumbWidth, $thumbHeight) = (98, 130); } elsif ($width == 1600 && $height == 1200) { ($newWidth, $newHeight) = (800, 600); ($thumbWidth, $thumbHeight) = (130, 98); } else { ($newWidth, $newHeight) = (600, 600); ($thumbWidth, $thumbHeight) = (98, 98); } my $newDimensions = $newWidth . 'x' . $newHeight; my @command = ('mogrify', '-quality', '100', '-geometry', $newDimensions, $newFile); print "mogrifying $newFile...\n"; system(@command);