From: l dot j dot peters at student dot utwente dot nl
Operating system: WinXP (all os)
PHP version: 5.1.5
PHP Bug Type: Feature/Change Request
Bug description: using imagecreatefromstring, howto get imagetype?
Description:
------------
I use imagecreatefromstring to load a binary stream, which is probably a
jpeg image (thumbnail).
With imagesx and imagesy I can retrieve the width and height of the
resource, but I cannot retrieve the imagetype or mimetype of the
resource.
As described in the imagecreatefromstring function documentation, the
imagetype will be automatically detected if the build of PHP can support
it.
Maybe an imagestype function can retrieve the imagetype from an image
resource?
Reproduce code:
---------------
<?php
$data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl'
. 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr'
. 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r'
. '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
$data = base64_decode($data);
$im = imagecreatefromstring($data);
echo "width: ".imagesx ($im)."\n";
echo "height: ".imagesy ($im)."\n";
echo "type: ".imagestype ($im)."\n";
?>
Expected result:
----------------
width: 28
height: 28
type: 3
Actual result:
--------------
width: 28
height: 18
PHP Fatal error: Call to undefined function imagestype() in %location%\-
on line 11
Fatal error: Call to undefined function imagestype() in %location%\- on
line 11
--
Edit bug report at http://bugs.php.net/?id=38526&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=38526&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=38526&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=38526&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38526&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=38526&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38526&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38526&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38526&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38526&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38526&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=38526&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=38526&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38526&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38526&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38526&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38526&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38526&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38526&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38526&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38526&r=mysqlcfg