|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-05-11 10:40 UTC] glen at delfi dot ee
Description: ------------ http://php.net/manual/en/function.imagick-thumbnailimage.php documents: "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 : #define IMAGICK_CALCULATE_THUMBNAIL_SIDES(magick_wand, 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 <?php $input_file = 'foo.jpg'; $width = 250; $height = 600; $im = new Imagick(); $im->readImage($input_file); echo "original: w={$im->getImageWidth()}; h={$im->getImageHeight()}\n"; $im->thumbnailImage($width, $height, true); echo "result: w={$im->getImageWidth()}; h={$im->getImageHeight()}\n"; PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 01:00:02 2025 UTC |
i workarounded problem for myself disabling the $fit = true and supplied properly calculated dimensions: <?php $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);