php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51556 imagepng,imagegif not function properly
Submitted: 2010-04-15 03:40 UTC Modified: 2010-04-15 19:21 UTC
From: luk-4u at hotmail dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.2.6 OS: centos5 x86_64 GNU/Linux
Private report: No CVE-ID: None
 [2010-04-15 03:40 UTC] luk-4u at hotmail dot com
Description:
------------
while running as cgi on nginx(the response is 'chunked' according to firebug), and ob_start is activated using imagepng,imagegif to outputimages to the browsers, these two are not correct, the browser only received part of the image, while imagejpeg is correct. And without ob_start or running as apache+mod_php(response not 'chunked') all three are correct. And if add 
'ob_end_clean()' before imagepng, it worked correctly. 

phpinfo:

gd
GD Support 	enabled
GD Version 	bundled (2.0.34 compatible)
FreeType Support 	enabled
FreeType Linkage 	with freetype
FreeType Version 	2.2.1
GIF Read Support 	enabled
GIF Create Support 	enabled
JPG Support 	enabled
PNG Support 	enabled
WBMP Support 	enabled
XBM Support 	enabled 

Test script:
---------------
ob_start();
header('Content-type: image/png');
imagepng(imagecreatefrompng('/home/webroot/a.png'));
//imagegif(imagecreatefrompng('/home/webroot/a.png'));
//imagejpeg(imagecreatefrompng('/home/webroot/a.png'));
exit;

Expected result:
----------------
the image rendered entirely 

Actual result:
--------------
firefox:the image rendered partly 
ie6: imagepng and imagegif behaves more weirdly 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-15 06:46 UTC] luk-4u at hotmail dot com
-PHP Version: 6SVN-2010-04-15 (SVN) +PHP Version: 5.2.6
 [2010-04-15 06:46 UTC] luk-4u at hotmail dot com
change php ver
 [2010-04-15 08:56 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2010-04-15 08:56 UTC] pajoye@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2010-04-15 10:41 UTC] luk-4u at hotmail dot com
-Status: Feedback +Status: Open
 [2010-04-15 10:41 UTC] luk-4u at hotmail dot com
test.php:

<?php
ob_start();
//ob_end_clean();
header('Content-type: image/png');
imagepng(imagecreatefrompng('/home/webroot/a.png'));
//imagepng(imagecreatefrompng('/home/webroot/a.png'), dirname(__FILE__).'/test.png');
//imagegif(imagecreatefrompng('/home/webroot/a.png'));
//imagejpeg(imagecreatefrompng('/home/webroot/a.png'));

exit;
?>

The script is as sime as above, and the environment is nginx+fastcgi(php5.2.6), assume u hv a vhost setted up and the file /home/webroot/a.png is available, just access it through http://ur_vhost_name.com/test.php

3ks
 [2010-04-15 10:59 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2010-04-15 10:59 UTC] pajoye@php.net
Works just fine here, with or without output buffering.

Please try using a recent PHP version as well, 5.2.6 is quite old (5.2.13 is the latest and recommended version for 5.2.x).
 [2010-04-15 13:33 UTC] luk-4u at hotmail dot com
-Status: Feedback +Status: Open
 [2010-04-15 13:33 UTC] luk-4u at hotmail dot com
thanks , ur sugggestion is correct.
 [2010-04-15 19:20 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2010-04-15 19:21 UTC] kalle@php.net
-Status: Closed +Status: Bogus -Assigned To: kalle +Assigned To:
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 23:01:29 2024 UTC