From: mmellon at ecrsoft dot com Operating system: Windows XP SP2 PHP version: 5.2.2 PHP Bug Type: GD related Bug description: imagewbmp(), image2wbmp not generating valid .bmp files
Description: ------------ I wrote a very simple class to represent code39 barcodes and output images and noticed that I could output a two-color image to png without issue, but the wbmp output is broken. When attempting to open the files generated by imagewbmp() or image2wbmp, mspaint throws an error dialog and states that it is not a valid file format. I am using Firefox to view png files and mspaint to view wbmp files. I installed php 5.2.2 (CLI only) with the gd extension using the installer from www.php.net. I will provide a very short code snippet that demonstrates the problem. I did note that in the gd2 docs there is a note about opening files for output under Windows - see note at: http://www.libgd.org/OldImageCreation#void_gdImageWBMP.28gdImagePtr_im.2C_int_fg.2C_FILE_.2Aout.29 (I'm not sure exactly how the gd extension works so I don't know if this has anything to do with it) Reproduce code: --------------- <?php $theimage = imagecreate(100,100); $black = imagecolorallocate($theimage,0,0,0); $white = imagecolorallocate($theimage,255,255,255); imagefilledrectangle($theimage, 10, 10, 89, 89, $white); imagewbmp($theimage, 'c:\sample1.bmp'); imagewbmp($theimage, 'c:\sample2.bmp', 127); image2wbmp($theimage, 'c:\sample3.bmp'); image2wbmp($theimage, 'c:\sample4.bmp',$white); image2wbmp($theimage, 'c:\sample5.bmp',$black); imagepng($theimage, 'c:\sample.png'); ?> Expected result: ---------------- I should be able to open sample.png and sample[n].bmp in respective viewers and see the same image. Actual result: -------------- sample.png opens in Firefox and shows a black square as expected. None of the sample wbmp files will open in mspaint, at all. -- Edit bug report at http://bugs.php.net/?id=41508&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41508&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41508&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41508&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41508&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41508&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41508&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41508&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41508&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41508&r=support Expected behavior: http://bugs.php.net/fix.php?id=41508&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41508&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41508&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41508&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41508&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41508&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41508&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41508&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41508&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41508&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41508&r=mysqlcfg