Bug #70441 [Csd]: interpolation modes broken in imagescale
| From: | programmer at bardware dot de | Date: | Fri, 14 Oct 2016 23:02:46 +0000 |
| Subject: | Bug #70441 [Csd]: interpolation modes broken in imagescale | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204784@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70441&edit=1
ID: 70441
User updated by: programmer at bardware dot de
Reported by: programmer at bardware dot de
Summary: interpolation modes broken in imagescale
Status: Closed
Type: Bug
Package: GD related
Operating System: Windows 7
PHP Version: 7.0.0RC2
Assigned To: pajoye
Block user comment: N
Private report: N
New Comment:
Finally realize it was fixed by https://bugs.php.net/bug.php?id=72227
Previous Comments:
------------------------------------------------------------------------
[2016-06-08 01:24:17] pajoye@php.net
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2016-06-07 21:10:14] programmer at bardware dot de
I cannot reproduce it with PHP 7.0.7-nts-Win32-VC14-x64. I had reproduced it with PHP 7.0.6 before.
------------------------------------------------------------------------
[2016-06-07 15:21:14] pajoye@php.net
Can you reproduce it with master, or 5.x? I cannot repro it on Windows (and linux too as you said).
------------------------------------------------------------------------
[2015-09-06 23:14:48] cmb@php.net
I can confirm this issue. The following script is supposed to
produce a plain red image:
<?php
$w1 = 1024; $h1 = 768;
$w2 = 640; $h2 = 480;
$img = imagecreatetruecolor($w1, $h1);
$red = imagecolorallocate($img, 255, 0, 0);
imagefilledrectangle($img, 0, 0, $w1, $h1, $red);
$scaledImage = imagescale($img, $w2, $h2, IMG_CATMULLROM);
imagepng($scaledImage, '70441.png');
?>
However, with PHP 7 on Windows (x86 and x64) it produces a checked
pattern. Linux builds don't seem to be affected. I've tested with
the bundled libgd only.
------------------------------------------------------------------------
[2015-09-06 18:35:16] programmer at bardware dot de
Description:
------------
I use the thread safe Version php-7.0.0RC2-Win32-VC14-x86.zip as provided on http://windows.php.net/qa/
I have a script to resize images. I use it with PHP 5.6 and everything's fine. The images are
broken (look bad) when the same script is used in PHP 7.
I found out that when I use another $mode in the call to imagescale(...) the images are correct.
I looped over all modes and it seems BICUBIX_FIXED, BILINEAR_FIXED and NEAREST_NEIGHBOUR are the
only ones producing good images.
I had been using CATMULLROM before.
Test script:
---------------
<?php
$arrInterpolMethod= [
"IMG_BELL" => IMG_BELL
, "IMG_BESSEL" => IMG_BESSEL
, "IMG_BICUBIC" => IMG_BICUBIC
, "IMG_BICUBIC_FIXED" => IMG_BICUBIC_FIXED
, "IMG_BILINEAR_FIXED" => IMG_BILINEAR_FIXED
, "IMG_BLACKMAN" => IMG_BLACKMAN
, "IMG_BOX" => IMG_BOX
, "IMG_BSPLINE" => IMG_BSPLINE
, "IMG_CATMULLROM" => IMG_CATMULLROM
, "IMG_GAUSSIAN" => IMG_GAUSSIAN
, "IMG_GENERALIZED_CUBIC" => IMG_GENERALIZED_CUBIC
, "IMG_HERMITE" => IMG_HERMITE
, "IMG_HAMMING" => IMG_HAMMING
, "IMG_HANNING" => IMG_HANNING
, "IMG_MITCHELL" => IMG_MITCHELL
, "IMG_POWER" => IMG_POWER
, "IMG_QUADRATIC" => IMG_QUADRATIC
, "IMG_SINC" => IMG_SINC
, "IMG_NEAREST_NEIGHBOUR" => IMG_NEAREST_NEIGHBOUR
, "IMG_WEIGHTED4" => IMG_WEIGHTED4
, "IMG_TRIANGLE" => IMG_TRIANGLE
];
if( $im = imagecreatefromjpeg( 'D:/Daten/Lumia_820/WP_20150829_028.jpg' ) ) {
$MaxWert = 2048;
$Width = ImagesX($im);
$Height = ImagesY($im);
if($Width>$Height) {
$NeuWidth = $MaxWert;
$NeuHeight = round( ( $Height * ($NeuWidth / $Width) ) / 4 ) * 4;
} else {
$NeuHeight = $MaxWert;
$NeuWidth = round( ( $Width * ($NeuHeight / $Height) ) / 4 ) * 4;
}
foreach( $arrInterpolMethod as $interpolName => $interpolConstant ) {
$NeuImg = imagescale( $im, $NeuWidth, $NeuHeight, $interpolConstant );
ImageInterlace( $NeuImg, 1 );
ImageJPEG($NeuImg, 'D:/Daten/php/WP_20150829_028_'.$interpolName.'.jpg', 80);
ImageDestroy($NeuImg);
}
ImageDestroy($im);
}
Expected result:
----------------
I expect to get 20 not broken looking images
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70441&edit=1