note 97017 added to function.imagick-setimagecompressionquality

From: Date: Sun, 28 Mar 2010 19:35:41 +0000
Subject: note 97017 added to function.imagick-setimagecompressionquality
Groups: php.notes 
Request: Send a blank email to php-notes+get-167466@lists.php.net to get a copy of this message
This is re-post of the previous post. I left out the part that removes the unnecessary data. Admins, if you could please delete the other comment I left. Thanks. This example shows how to set the compression type, set the compression quality, create a thumbnail and remove unnecessary data in order to reduce file size. This will use the following functions in reference: Imagick::setImageCompression Imagick::setImageCompressionQuality Imagick::stripImage Imagick::thumbnailImage Imagick::writeImage <?php $image = 'image.jpg'; $directory = '/path/to/image'; $image_location = $directory . "/" . $image; $thumb_destination = $directory . "/t" . $image; $compression_type = Imagick::COMPRESSION_JPEG; $im = new Imagick($image_location); $thumbnail = $im->clone; $thumbnail->setImageCompression($compression_type); $thumbnail->setImageCompressionQuality(40); $thumbnail->stripImage(); $thumbnail->thumbnailImage(100,null); $thumbnail->writeImage($thumb_destination); ?> Now, obviously you don't have to do so much with the variables and the file location. I only used so many to demonstrate where the images are coming from and where they are going. NOTE: The $thumbnail->thumbnailImage(100,null); keeps the aspect ration by setting the second parameter to null. Read about this at Imagick::thumbnailImage There is another way to create thumbnails that works quite well if you want to crop the image rather than using the entire image. Check out Imagick::cropThumbnailImage ---- Server IP: 69.147.83.197 Probable Submitter: 65.12.181.174 ---- Manual Page -- http://www.php.net/manual/en/function.imagick-setimagecompressionquality.php Edit -- https://master.php.net/note/edit/97017 Del: integrated -- https://master.php.net/note/delete/97017/integrated Del: useless -- https://master.php.net/note/delete/97017/useless Del: bad code -- https://master.php.net/note/delete/97017/bad+code Del: spam -- https://master.php.net/note/delete/97017/spam Del: non-english -- https://master.php.net/note/delete/97017/non-english Del: in docs -- https://master.php.net/note/delete/97017/in+docs Del: other reasons-- https://master.php.net/note/delete/97017 Reject -- https://master.php.net/note/reject/97017 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#167466) next »