|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71316 libpng warning from imagecreatefromstring
Submitted: 2016-01-08 22:07 UTC Modified: 2017-10-24 07:38 UTC
Avg. Score:4.0 ± 0.8
Reproduced:15 of 15 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (6.7%)
From: humbads at alum dot mit dot edu Assigned:
Status: Open Package: GD related
PHP Version: 5.6.17 OS: FreeBSD 10.2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-01-08 22:07 UTC] humbads at alum dot mit dot edu
imagecreatefromstring is writing a warning message to stderr that can not be suppressed by '@' or captured by the error handler.  It should emit a proper PHP warning instead.

I have the following version of libPNG:

php -i | grep -i libpng
libPNG Version => 1.6.19+apng

To run the test script, download the sample PNG image from here:

Note: libPNG 1.5.18 on PHP 5.6.17 for Windows does not have this problem.

Test script:
php -r '@var_dump(imagecreatefromstring(file_get_contents("1CCHOHSULGF78KW.png")));' 

Expected result:
resource(6) of type (gd)

Actual result:
libpng warning: iCCP: known incorrect sRGB profile
resource(6) of type (gd)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-08 22:27 UTC] humbads at alum dot mit dot edu
A workaround is to run the following ImageMagick command on the PNG file before processing:

mogrify -strip 1CCHOHSULGF78KW.png

 [2016-01-10 01:48 UTC]
-Assigned To: +Assigned To: pajoye
 [2016-01-10 01:48 UTC]
Thanks for your report!

Hm. This is a libpng warning.I suppose they move this warning to a simple warning level. 

I will see if we can implement the warning only callback without introducing too much noises:

 png_structp png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn);

only png_error is used now and generates php error.
 [2016-07-17 21:57 UTC] michael dot hartmann at refx dot com
PHP 7.0.8 x64 on Windows. Same problem. Please fix.
 [2016-09-05 09:47 UTC]
This appears to be a general libgd issue, so I've reported
<> upstream.
 [2017-10-24 07:38 UTC]
-Status: Assigned +Status: Open -Assigned To: pajoye +Assigned To:
 [2018-07-13 08:31 UTC] divinity76+spam at gmail dot com
can reproduce on php 7.1.17 @ ubuntu 17.10  (aka i inconveniently encountered this bug)
 [2018-07-13 09:29 UTC] divinity76 at gmail dot com
can't be captured with ob_start() either, does anybody have a workaround?
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Jul 09 19:01:28 2020 UTC