php.net |  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: bfrance@php.net 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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bfrance@php.net
New email:
PHP Version: OS:

 

 [2010-02-16 21:54 UTC] bfrance@php.net
Description:
------------
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.

http://www.brianfrance.com/software/php/getimagesizefromstring.diff



Reproduce code:
---------------
<?PHP
$img = 'test.gif';

var_dump(getimagesize($img));

$data = file_get_contents($img);

var_dump(getimagesizefromstring($data));
?>



Patches

Pull Requests

History

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

http://www.brianfrance.com/software/php/getimagesizefromstring/001.phpt

and the required test.gif (php logo image):

http://static.php.net/www.php.net/images/php.gif
 [2010-02-17 14:25 UTC] pajoye@php.net
Will apply it shortly after review (probably this WE). However it looks good already, thanks :)
 [2010-03-06 12:01 UTC] kalle@php.net
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] pajoye@php.net
-Package: Feature/Change Request +Package: GetImageSize related
 [2010-05-05 15:37 UTC] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=299021
Log: - #51063, implement getimagesizefromstring
 [2010-05-05 15:39 UTC] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=299022
Log: - #51063, news and test
 [2010-05-05 15:40 UTC] pajoye@php.net
-Status: Assigned +Status: Closed
 [2010-05-05 15:40 UTC] pajoye@php.net
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
http://snaps.php.net/.
 
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: Sun Oct 27 16:01:27 2024 UTC