|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58667 thumbnailImage() (and others) with $fit = true overscale image
Submitted: 2009-05-11 10:40 UTC Modified: 2009-07-02 18:17 UTC
From: glen at delfi dot ee Assigned:
Status: No Feedback Package: imagick (PECL)
PHP Version: 5.2.9 OS: PLD Linux
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:
Bug Type:
From: glen at delfi dot ee
New email:
PHP Version: OS:


 [2009-05-11 10:40 UTC] glen at delfi dot ee

"If TRUE is given as a third parameter then columns and 
rows parameters are used as maximums for each side. Both 
sides will be scaled down until the match or are smaller 
than the parameter given for the side."

however having input image with 401x600 pixels, scaled 
down to 250x600, results me given image 401x600. it seems 
it's due the macro reseting desired_width to 0, thus 
losing the information given as $width parameter.

php_imagick_macros.h :
desired_width, desired_height, fit) \
        } else { \
            if (orig_height > orig_width) { \
                desired_width = 0; \
            } else { \
                desired_height = 0; \
            } \

Reproduce code:
// create sample image:
$ convert -size 401x600 plasma:fractal foo.jpg
// run the script:
$ php test.php
original: w=401; h=600
result: w=401; h=600

// script itself:
$ cat test.php
$input_file = 'foo.jpg';
$width = 250;
$height = 600;

$im = new Imagick();
echo "original: w={$im->getImageWidth()}; h={$im->getImageHeight()}\n";
$im->thumbnailImage($width, $height, true);
echo "result: w={$im->getImageWidth()}; h={$im->getImageHeight()}\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-11 10:43 UTC] glen at delfi dot ee
i workarounded problem for myself disabling the $fit = 
true and supplied properly calculated dimensions:

    $ow = $im->getImageWidth();
    $oh = $im->getImageHeight();

    // take the smallest proportion and use that as size 
ratio multiplier
    $ratio = $width / $ow < $height / $oh ? $width / $ow : 
$height / $oh;
    $width = floor($ow * $ratio);
    $height = floor($oh * $ratio);
 [2009-05-13 18:02 UTC]
Hi, can you test the CVS version?
 [2009-05-14 05:20 UTC] glen at delfi dot ee
i tested also with 2.3.0RC1, the code was not changed in that
header file.
 [2009-05-14 05:29 UTC]

cvs -d checkout pecl/imagick && cd pecl/imagick && phpize && ./configure && make install
 [2009-05-14 05:40 UTC] glen at delfi dot ee
unfortunately i can't test right now, seems i need to upgrade
imagick first (i have installed):

warning: no newline at end of file
/home/glen/rpm/pld/BUILD/imagick/imagick_read.c: In function
/home/glen/rpm/pld/BUILD/imagick/imagick_read.c:94: error:
too few arguments to function `count_occurences_of'
make: *** [imagick_read.lo] Error 1
make: *** Waiting for unfinished jobs....
/home/glen/rpm/pld/BUILD/imagick/imagick_helpers.c: In
function `php_imagick_validate_map':
warning: initialization discards qualifiers from pointer
target type
/home/glen/rpm/pld/BUILD/imagick/imagick_helpers.c: In
function `initialize_imagick_constants':
error: `OptimizeImageLayer' undeclared (first use in this
error: (Each undeclared identifier is reported only once
error: for each function it appears in.)
error: `OptimizeTransLayer' undeclared (first use in this
error: `RemoveDupsLayer' undeclared (first use in this
error: `RemoveZeroLayer' undeclared (first use in this
error: `CompositeLayer' undeclared (first use in this
make: *** [imagick_helpers.lo] Error 1
error: Bad exit status from /home/glen/tmp/rpm-tmp.95759
 [2009-05-14 06:01 UTC]
Should be fixed now. Can you retest? Build against thread safe php was broken (i hardly ever test it)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 09:01:29 2024 UTC