use Image::Magick; ... # Check and change image height if necessary my ($height,$width); ($height,$width) = $image->GetAttribute('height','width'); if ( $height > 300 ) { my ($newheight,$newwidth); $newheight = 300; $newwidth = ($width*$newheight)/$height; $image->Scale('height'=>$newheight,'width'=>$newwidth); } # Check and change image width if necessary ($height,$width) = $image->GetAttribute('height','width'); if ( $width > 250 ) { my ($newheight,$newwidth); $newwidth = 250; $newheight = ($height*$newwidth)/$width; $image->Scale('width'=>$newwidth,'height'=>$newheight); } #### # Adjust Resolution if necessary $image->SetAttribute('units'=>'PixelsPerInch'); my ($xrez,$yrez) = $image->GetAttribute('x-resolution', 'y-resolution'); if ($xrez > 72 || $yrez > 72) { $image->SetAttribute('density'=>'72x72'); } #### x-resolution is 300 y-resolution is 300 #### x-resolution is 72 y-resolution is 72