note 97016 added to function.imagick-cropthumbnailimage

From: Date: Sun, 28 Mar 2010 18:55:55 +0000
Subject: note 97016 added to function.imagick-cropthumbnailimage
Groups: php.notes 
Request: Send a blank email to php-notes+get-167465@lists.php.net to get a copy of this message
If you are looking for a way to make a cropped thumbnail that maintains good quality and low file size, the below method may be good for you. I will reference the following functions: Imagick::setImageCompression Imagick::setImageCompressionQuality Imagick::stripImage Imagick::cropthumbnailImage 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->cropthumbnailImage(100,100); $thumbnail->writeImage($thumb_destination); ?> NOTE: The Imagick::stripImage will remove all the EXIF data contained in the image. Some digital cameras will embed a thumbnail of their own in this data (if I remember correctly.) It is possible to actually extract the embedded thumbnail and use that if you would like. I have not tried it so I can't tell you about the file sizes. What I can tell you is by removing this data from the image I shaved quite a bit of data off of my images. If you would like to simply create a thumbnail that is not cropped check out the Imagick::thumbnailImage reference. ---- Server IP: 69.147.83.197 Probable Submitter: 65.12.181.174 ---- Manual Page -- http://www.php.net/manual/en/function.imagick-cropthumbnailimage.php Edit -- https://master.php.net/note/edit/97016 Del: integrated -- https://master.php.net/note/delete/97016/integrated Del: useless -- https://master.php.net/note/delete/97016/useless Del: bad code -- https://master.php.net/note/delete/97016/bad+code Del: spam -- https://master.php.net/note/delete/97016/spam Del: non-english -- https://master.php.net/note/delete/97016/non-english Del: in docs -- https://master.php.net/note/delete/97016/in+docs Del: other reasons-- https://master.php.net/note/delete/97016 Reject -- https://master.php.net/note/reject/97016 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#167465) next »