|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79158 PHP-gd imagecreatefrombmp fails on 1-bit BMP
Submitted: 2020-01-23 08:03 UTC Modified: 2020-01-23 08:28 UTC
From: php dot bugreport at tbspace dot de Assigned: cmb (profile)
Status: Duplicate Package: GD related
PHP Version: 7.4.1 OS: Linux x64
Private report: No CVE-ID: None
 [2020-01-23 08:03 UTC] php dot bugreport at tbspace dot de
When loading a 1-bit BMP bitmap with gd's imagecreatefrombmp, the resulting image data is corrupted (skewed?). 

Here's a screenshot of the problem:

And here's a test 1-bit bitmap:

All other tools I tried (ImageMagick, IrfanView, MS Paint) can open this file just fine, so I think this is a PHP-GD issue. 

Test script:
$im = imagecreatefrombmp("042-1rr1.bmp");

Expected result:
Binary data. Write to a .png file with php test.php > test.png and open the .png file in an image viewer. 

Actual result:
Resulting .png image is skewed/corrupted. 
(see screenshot in description for an example)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-23 08:28 UTC]
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2020-01-23 08:28 UTC]
This is a duplicate of bug #77391, which is fixed in PHP's bundled
libgd as of PHP 7.2.15/7.3.2; it also has been fixed in the
development branch of upstream[1], but no new release has been
made since then.

[1] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Feb 24 17:01:32 2024 UTC