|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-09-06 18:35 UTC] 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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 05:00:01 2025 UTC |
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.