|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51063 Add getimagesizefromstring
Submitted: 2010-02-16 21:54 UTC Modified: 2010-05-05 15:40 UTC
From: Assigned: pajoye (profile)
Status: Closed Package: GetImageSize related
PHP Version: 5.3.1 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
New email:
PHP Version: OS:


 [2010-02-16 21:54 UTC]
It would be nice to be able to pass in a string to getimagesize.

Here is a patch that takes the original getimagesize function and turns it into php_getimagesize_from_stream.  Then getimagesize and a new function getimagesizefromstring can use the function once a stream is created.

Reproduce code:
$img = 'test.gif';


$data = file_get_contents($img);



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-02-17 03:59 UTC]
Here is a test for the new function:

and the required test.gif (php logo image):
 [2010-02-17 14:25 UTC]
Will apply it shortly after review (probably this WE). However it looks good already, thanks :)
 [2010-03-06 12:01 UTC]
Patch looks good except for one thing, that is the parameter parsing. You should 
use something along the lines of:

char *file;
int file_len;
HashTable *ht;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMS_CC, "s|H", &file, &file_len, 
&ht) == FAILURE)

The old (and deprecated) way of first doing a switch and use 
zend_get_parameters*() should be avoided.

Else good work on the patch ;)
 [2010-05-05 10:17 UTC]
-Package: Feature/Change Request +Package: GetImageSize related
 [2010-05-05 15:37 UTC]
Automatic comment from SVN on behalf of pajoye
Log: - #51063, implement getimagesizefromstring
 [2010-05-05 15:39 UTC]
Automatic comment from SVN on behalf of pajoye
Log: - #51063, news and test
 [2010-05-05 15:40 UTC]
-Status: Assigned +Status: Closed
 [2010-05-05 15:40 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

Applied a slightly cleaner patch.

Thanks for your work!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 13 01:01:30 2024 UTC