note 119416 added to imagick.resizeimage
| From: | phper at krzysiu dot net | Date: | Thu, 02 Jun 2016 00:41:34 +0000 |
| Subject: | note 119416 added to imagick.resizeimage | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-205634@lists.php.net to get a copy of this message | ||
Some size, image and filter and blur combinations causes artifacts or even make image completely
scrambled. As far, as I see, it happens with blur values smaller than 0.25 (sometimes less) and goes
worse to the point of 0 - black image. Sometimes only some values gives artifacts, like Hanning with
my test image: 0.0 blur is fine, 0.1 produces artefacts.
Affected filters are e.g. Catrom, sinc, cubic, quadratic, while unaffected are e.g. Lanczos and
Hanning. The problem seems to be the domain of the filter algorithms, not IMagick implementation.
This image shows three filters: http://i.imgur.com/HcdwoUS.jpg
Sometimes test image could look fine, but other not, so if you are using affected filters, the 0.5
value should be safe.
This test script takes example image (you can download and use http://i.imgur.com/KsTJpFr.jpg which is affected) and
creates resized images in the same directory for every filter and one of four blur values, with
naming like "test.jpg.sinc.0.1.jpg" for "test.jpg" input.
<?php
$imgPath = 'imgtest/test.jpg'; // set your image file
$testBlurs = [0, 0.1, 0.2, 0.5]; // test these blur values
$im = new IMagick();
$im->readImage($imgPath);
foreach ((new ReflectionClass('IMagick'))->getConstants() as $n => $f) {
if (strncmp($n, 'FILTER_', 7) === 0) { // get available IMagick filters
$filterName = strtolower(substr($n, 7)); // extract filter name from constant
foreach ($testBlurs as $blur) {
$imSize = clone $im;
$imSize->resizeImage(500, 500, $f, $blur, true);
$imSize->writeImage(sprintf("%s-%s-%.1f.jpg", $imgPath, $filterName, $blur));
$imSize->destroy();
}
}
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 89.68.252.232
----
Manual Page -- http://php.net/manual/en/imagick.resizeimage.php
Edit -- https://master.php.net/note/edit/119416
Del: integrated -- https://master.php.net/note/delete/119416/integrated
Del: useless -- https://master.php.net/note/delete/119416/useless
Del: bad code -- https://master.php.net/note/delete/119416/bad+code
Del: spam -- https://master.php.net/note/delete/119416/spam
Del: non-english -- https://master.php.net/note/delete/119416/non-english
Del: in docs -- https://master.php.net/note/delete/119416/in+docs
Del: other reasons-- https://master.php.net/note/delete/119416
Reject -- https://master.php.net/note/reject/119416
Search -- https://master.php.net/manage/user-notes.php