php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42062 imagegrabscreen() returns corrupted GD resource
Submitted: 2007-07-21 19:01 UTC Modified: 2008-11-10 01:00 UTC
Votes:5
Avg. Score:4.2 ± 1.0
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:2 (50.0%)
From: fumble1 at web dot de Assigned: pajoye (profile)
Status: No Feedback Package: GD related
PHP Version: 5.2.3 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fumble1 at web dot de
New email:
PHP Version: OS:

 

 [2007-07-21 19:01 UTC] fumble1 at web dot de
Description:
------------
imagegrabscreen() returns a corrupted GD resource, which causes imagepng() to bail out.

Reproduce code:
---------------
<?php
$im = imagegrabscreen();
imagepng($im, 'screenshot.png');
?>

Expected result:
----------------
A screenshot being created in the working dir or an error message from imagegrabscreen().

Actual result:
--------------
"Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 3840 bytes) in __FILE__ on line  3" (imagepng()) and an empty PNG-file that httpd.exe kept open, so it couldn?t be deleted.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-21 19:06 UTC] pajoye@php.net
"Fatal error: Allowed memory size of 8388608 bytes exhausted"

Increase your memory limit.
 [2007-07-21 19:25 UTC] pajoye@php.net
Thanks to Derick, I miss the "can't be deleted" part.
 [2007-07-22 12:59 UTC] fumble1 at web dot de
Guess I was on the wrong track... that "file-can?t-be-deleted-'cause-it?s-used-by-another-process" thingy is caused by the imageoutput-functions failing on memory_limit. Sorry for accusing imagegrabscreen().

pajoye> "Increase your memory limit."
That got me an all-black PNG the size of my screen, just to note that.
 [2007-07-22 13:42 UTC] pajoye@php.net
"That got me an all-black PNG the size of my screen, just to note that."

Where do you run PHP, in IIS/Apache?

The blank screen is often due to apache or what ever php is running in not having permission to interact with the desktop. 

To solve this, goto the computers services find your service, goto properties, select logon and check the box that allows the service to interact with the desktop.
 [2007-07-22 14:16 UTC] fumble1 at web dot de
pajoye> "Where do you run PHP, in IIS/Apache?"
Apache, right.

pajoye> "To solve this, goto the computers services find your service, goto
properties, select logon and check the box that allows the service to
interact with the desktop."
That worked, thank you.

Do I have to open a new "ticket" on
> "that
"file-can?t-be-deleted-'cause-it?s-used-by-another-process" thingy [...] caused by the imageoutput-functions failing on memory_limit"
or will that do?
 [2007-07-22 14:27 UTC] pajoye@php.net
> Do I have to open a new "ticket"

This one is enough. Not sure if it comes from gd or the php stream.

The black image is not a bug.
 [2007-07-25 08:40 UTC] pajoye@php.net
Thanks to Dmitry for the quick debug, here is the explanation:

php_image_output_ctx() does fopen(), then memory overflow occurs that does longjump, so corresponding fclose() is never called.

A fix will be done as soon as possible, I hope I can manage to do it for the upcoming 5.2.4.
 [2008-11-02 12:51 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2008-11-10 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 12 16:01:35 2024 UTC