Bug #17528 Updated: imagecreatefromstring() enhancement suggestions
| From: | sniper@php.net | Date: | Fri, 28 Jun 2002 09:25:02 +0000 |
| Subject: | Bug #17528 Updated: imagecreatefromstring() enhancement suggestions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-12381@lists.php.net to get a copy of this message | ||
ID: 17528
Updated by: sniper@php.net
Reported By: sonnysavage@yahoo.com
-Status: Open
+Status: Closed
Bug Type: GD related
Operating System: Windows 98 (1st ed)
PHP Version: 4.2.1
New Comment:
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a
documentation
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.
I fixed the crash bug.
Previous Comments:
------------------------------------------------------------------------
[2002-06-01 20:39:34] sonnysavage@yahoo.com
After more searching, I discovered that the variable name had been
mistyped. I had been passing the function an empty string. My code is
working correctly now.
Based on my experience, I'd like to suggest the following
enhancements:
1. The function should be more robust and not crash the web server
when it gets bad data.
2. When data is not an image at all (i.e. and empty string), the error
message should reflect that.
-> Passed data was null
-> Passed data was not a valid image
------------------------------------------------------------------------
[2002-05-30 21:45:36] sonnysavage@yahoo.com
On trying to fulfill your request for a self-contained example, I
discovered that I wasn't getting the entire image into the database
(fopen() on Win32). I think that the imagecreatefromstring() function
should be able to more robustly handle input.
Now I have a different problem. The data string I am retrieving is a
JPEG. The error message I get is:
Warning: imagecreatefromstring: Passed data is not in 'WBMP' format in
c:\www\mcsda\includes\class.image.php on line 16
Warning: Couldn't create GD Image Stream out of Data in
c:\www\mcsda\includes\class.image.php on line 16
I know that my string is not in WBMP format. Is that the only format
this function can take as input?
------------------------------------------------------------------------
[2002-05-30 18:09:22] mfischer@php.net
Please provide a small, self-contained example (read: not database
dependency) which reproduces the problem.
------------------------------------------------------------------------
[2002-05-30 10:30:06] sonnysavage@yahoo.com
My machine is a Pentium 233MMX with 160 MB RAM.
I have tested this with:
Apache 1.3.24 AND 2.0.36
PHP 4.2.1 - php_gd.dll AND php_gd2.dll (only one at a time)
Here is the code being executed:
$query = "SELECT image, width, height FROM site_image";
$query .= " WHERE image_id=\"".$image_id."\";";
$result = mysql_query($query, $linkid);
$rowarray = mysql_fetch_array($result, MYSQL_ASSOC);
$old_image = imagecreatefromstring($rowarray["image"]);
I know that it is the imagecreatefromstring() function causing the
crash because when I remove it, the code doesn't work, but it doesn't
crash either.
I get the error:
"This program has performed and illegal operation and will be shut
down."
These are the details:
APACHE caused an invalid page fault in
module PHP_GD2.DLL at 0197:017c1317.
Registers:
EAX=05095000 CS=0197 EIP=017c1317 EFLGS=00010246
EBX=00000000 SS=019f ESP=0195f7e8 EBP=0195f7f8
ECX=00000000 DS=019f ESI=007a6b50 FS=8b27
EDX=ffffe2ee ES=019f EDI=00000001 GS=0000
Bytes at CS:EIP:
8a 08 89 4d fc 8b 55 f0 83 c2 01 89 55 f0 33 c0
Stack dump:
05095000 ffffe2ee 006d78d0 00000000 0195f808 017c1dc9 0195f93c 000000da
0195f820 017d2b05 0195f93c 017d2f44 006d78b8 006d78d0 0195f834 017c05c6
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17528&edit=1