| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2009-12-22 10:04 UTC] jani@php.net
  [2009-12-23 12:58 UTC] pajoye@php.net
  [2009-12-31 01:00 UTC] php-bugs at lists dot php dot net
  | 
    |||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 13:00:02 2025 UTC | 
Description: ------------ When using imagecopyresampled on a CentOS 5.3 and PHP 5.2.9 (also tried the 5.3 snapshot) multi-colored pixels are sprinkled onto the image. Running the same function in a loop produces a different image every time using the same input. I could not reproduce the issue on another CentOS 5.3 machine so I think it could be related to the floating point unit on the box. Here is the cpuinfo: processor : 0 vendor_id : AuthenticAMD cpu family : 6 model : 8 model name : AMD Athlon(tm) XP 2000+ stepping : 1 cpu MHz : 1662.500 cache size : 256 KB fdiv_bug : no hlt_bug : no f00f_bug : no coma_bug : no fpu : yes fpu_exception : yes cpuid level : 1 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 mmx fxsr sse syscall mmxext 3dnowext 3dnow up nonstop_tsc ts bogomips : 3326.67 To work around the issue for now, I changed the resample function in the bundled gd library to use floats instead of doubles, and then used the compiler flags -msse -mfpmath=sse to force the use of the SSE unit instead of the built in FPU. This produced clean images! In the GCC documentation, this model of CPU doesn't support doubles for SSE instructions so that is why I changed them to floats. Reproduce code: --------------- <?php $img = imagecreatefromjpeg("photo.jpg"); list($img_width, $img_height, $img_type, $img_attr) = getimagesize("photo.jpg"); $new_width = 300; $new_height = 400; for ($i = 0; $i < 10; $i++) { $nimg = imagecreatetruecolor($new_width, $new_height); imagecopyresampled ($nimg, $img, 0, 0, 1, 1, $new_width, $new_height, $img_width - 2, $img_height - 2); imagejpeg($nimg, "output$i.jpg", 80); imagedestroy($nimg); } ?> Expected result: ---------------- Resized photos without noise. Here is the original photo used in the resample: http://bit.ly/yfS5w Actual result: -------------- Resized photo with noise, result is different each time. Here are three examples: http://bit.ly/SOzNV http://bit.ly/oXUsm http://bit.ly/6gsCP