my ($w,$h)=$img->Get('width','height'); my $want_aspect=3/2; my $is_aspect=$w/$h; if($want_aspect-$is_aspect > 0) { $w=int((1/$want_aspect)*$h); } else { $h=int($want_aspect*$w); } $img->Crop(width=>$w, height=>$h, gravity=>'Center');