php.net |  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
Description:
------------
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: 
https://screenshot.tbspace.de/wjstqfduhnk.png

And here's a test 1-bit bitmap:
https://tbspace.de/content/downloads/042-1rr1.bmp

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:
---------------
<?php
$im = imagecreatefrombmp("042-1rr1.bmp");
imagepng($im);


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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-23 08:28 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2020-01-23 08:28 UTC] cmb@php.net
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] <https://github.com/libgd/libgd/issues/450>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 03 20:01:29 2024 UTC