note 110577 modified in imagick.scaleimage by danbrown

From: Date: Thu, 06 Dec 2012 14:20:28 +0000
Subject: note 110577 modified in imagick.scaleimage by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192325@lists.php.net to get a copy of this message
Need to resize portrait and landscape images (and convert to 72ppi)? These will fit an area of 800x600 without distorting, no matter how tall or wide. <?php $img = new Imagick($img_loc.$file); $img->setImageResolution(72,72); $img->resampleImage(72,72,imagick::FILTER_UNDEFINED,1); $img->scaleImage(800,0); $d = $img->getImageGeometry(); $h = $d['height']; if($h > 600) { $img->scaleImage(0,600); $img->writeImage($resized_loc.$file); } else { $img->writeImage($resized_loc.$file); } $img->destroy(); ?> --was-- Need to resize portrait and landscape images (and convert to 72ppi)? These will fit an area of 800x600 without distorting, no matter how tall or wide. $img = new Imagick($img_loc.$file); $img->setImageResolution(72,72); $img->resampleImage(72,72,imagick::FILTER_UNDEFINED,1); $img->scaleImage(800,0); $d = $img->getImageGeometry(); $h = $d['height']; if($h > 600) { $img->scaleImage(0,600); $img->writeImage($resized_loc.$file); } else { $img->writeImage($resized_loc.$file); } $img->destroy(); http://php.net/manual/en/imagick.scaleimage.php

« previous php.notes (#192325) next »