php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41508 imagewbmp(), image2wbmp not generating valid .bmp files
Submitted: 2007-05-27 02:02 UTC Modified: 2007-05-27 02:05 UTC
From: mmellon at ecrsoft dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.2.2 OS: Windows XP SP2
Private report: No CVE-ID: None
 [2007-05-27 02:02 UTC] mmellon at ecrsoft dot com
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-27 02:05 UTC] mmellon at ecrsoft dot com
I had confused WBMP format with DIB... oops.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 05:01:28 2024 UTC