php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58607 Twice crop returns invalid result
Submitted: 2009-03-30 17:53 UTC Modified: 2009-04-01 14:53 UTC
From: adrive at hip-hop dot sk Assigned:
Status: Closed Package: imagick (PECL)
PHP Version: 5.2.6 OS: Debian Lenny
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: adrive at hip-hop dot sk
New email:
PHP Version: OS:

 

 [2009-03-30 17:53 UTC] adrive at hip-hop dot sk
Description:
------------
Crop won't work as I expected. I cannot crop image twice.

When I crop image first time, the result is as expected, but when I crop the image afterwards, the result is in another size. Doesn't matter wheter I am using cropImage function or cropImageThumbnail.

It doesn't matter whether I am cloning the object or crop the same instance of object twice. The result is the same - invalid dimensions of the last image.

Reproduce code:
---------------
$res = new Imagick('/home/kmet/teaser_image.jpg');
header('Content-type: image/jpeg;');
$res->cropThumbnailImage(100, 100);
// echo $res 

$thumb = $res->clone();
$thumb->cropThumbnailImage(100, 40);
echo $thumb;

Expected result:
----------------
cropThumbnailImage on the 3rd line works well. The image is resized and cropped to center perfectly and the new image dimesions are now 100x100 pixels.

cropThIm on the 7th line crops the image, but the new image dimensions are strange for some reasons: 45x40 pixels. Not the expected 100x40.

Actual result:
--------------
$thumb->cropThumnailImage(100x100) returns 100x100 pixels image
$thumb->cropThumnailImage(100x40) returns 45x40 pixels image afterwards.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-01 14:53 UTC] mkoppanen@php.net
Hello, 

try the following code:

$res = new Imagick('/home/kmet/teaser_image.jpg');
header('Content-type: image/jpeg;');
$res->cropThumbnailImage(100, 100);
$res->setImagePage(100, 100, 0, 0);
// echo $res 

$thumb = $res->clone();
$thumb->cropThumbnailImage(100, 40);
echo $thumb;

I added a call to MagickSetImagePage from cropThumbnailImage as well and it should be in the next release.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 08:01:32 2024 UTC