php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #38526 using imagecreatefromstring, howto get imagetype?
Submitted: 2006-08-20 19:43 UTC Modified: 2006-08-20 19:54 UTC
From: l dot j dot peters at student dot utwente dot nl Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.1.5 OS: WinXP (all os)
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: l dot j dot peters at student dot utwente dot nl
New email:
PHP Version: OS:

 

 [2006-08-20 19:43 UTC] l dot j dot peters at student dot utwente dot nl
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-20 19:54 UTC] pajoye@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

there is no imagestype function and imagecreatefromstring returns a GD resource, you can use it to export its content in any format supported by gd.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 03:01:28 2024 UTC