note 117087 added to imagick.cropimage
| From: | oxxido at gmail dot com | Date: | Mon, 13 Apr 2015 17:58:26 +0000 |
| Subject: | note 117087 added to imagick.cropimage | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202249@lists.php.net to get a copy of this message | ||
I have a function that takes an image, resize and crop it, and save it as normal, then resize it
again and crop it again to create the thumbnail. The numbers of the second crop were WAY off, and
the calculations were perfect, the problem, was the second crop wasn't resetting the imagePage,
so if you try to crop the same image twice, it will be a good idea to reset it first:
<?php
$thumb = new Imagick($file)
$thumb->resizeImage($r_w1,$r_h1,Imagick::FILTER_CATROM,0.9, false);
$thumb->cropImage($w1,$h1,$l1,$t1);
$thumb->writeImage($destinationPath.'/'.$fileName);
$thumb->resizeImage($r_w2,$r_h2,Imagick::FILTER_CATROM,0.9, false);
$thumb->setImagePage(0, 0, 0, 0);
$thumb->cropImage($w2,$h2,$l2,$t2);
$thumb->writeImage($destinationPath.'/'.$fileNameThumb);
?>
BTW, i needed perfect dimentions so i had to set the "bestfit" to false.
----
Server IP: 72.52.91.14
Probable Submitter: 190.30.137.217
----
Manual Page -- http://php.net/manual/en/imagick.cropimage.php
Edit -- https://master.php.net/note/edit/117087
Del: integrated -- https://master.php.net/note/delete/117087/integrated
Del: useless -- https://master.php.net/note/delete/117087/useless
Del: bad code -- https://master.php.net/note/delete/117087/bad+code
Del: spam -- https://master.php.net/note/delete/117087/spam
Del: non-english -- https://master.php.net/note/delete/117087/non-english
Del: in docs -- https://master.php.net/note/delete/117087/in+docs
Del: other reasons-- https://master.php.net/note/delete/117087
Reject -- https://master.php.net/note/reject/117087
Search -- https://master.php.net/manage/user-notes.php