use strict; use warnings; use Image::Magick; use File::Spec::Functions qw(splitpath); my $thumbX = 100; my $thumbY = 66; my $filename = shift; my $image = Image::Magick->new (); $image->ReadImage ($filename); my ($height, $width) = $image->Get ('height', 'width'); my ($x, $y) = $height < $width ? ($thumbX, $thumbY) : ($thumbY, $thumbX); my ($drive, $dir, $file) = splitpath ($filename); $file =~ s/(\..*?)$/_s$1/; $image->Thumbnail (width=>$x, height=>$y); $image->Write ("$drive${dir}$file");