Req #62961 [Opn]: please add exif_imagetypefromstring
| From: | laruence@php.net | Date: | Wed, 29 Aug 2012 09:29:25 +0000 |
| Subject: | Req #62961 [Opn]: please add exif_imagetypefromstring | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-172997@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62961&edit=1
ID: 62961
Updated by: laruence@php.net
Reported by: scott dot jungwirth at demandmedia dot com
Summary: please add exif_imagetypefromstring
Status: Open
Type: Feature/Change Request
Package: EXIF related
Operating System: CentOS
PHP Version: 5.3.16
Block user comment: N
Private report: N
New Comment:
hmm, how about (rfc 2397):
$extension = image_type_to_extension(exif_imagetype("data://image/;base64," .
base64_encode($bin_data)));
Previous Comments:
------------------------------------------------------------------------
[2012-08-29 01:02:21] scott dot jungwirth at demandmedia dot com
Description:
------------
It would be nice to have an exif_imagetypefromstring function to determine an
image type from a string without having to save the string to a file in order to
use the exif_imagetype function.
There is a getimagesizefromstring function in PHP 5.4 but exif_imagetype is
supposed to be much faster as it only needs to look at the first couple of bytes
of the string to determine the image type.
My problem is I can't really take advantage of the faster behavior because my
image data is in a string, not in a file.
Test script:
---------------
<?php
$extension = image_type_to_extension(exif_imagetypefromstring($bin_data));
// versus
$tmpfile = tempnam('/tmp', 'upload');
file_put_contents($tmpfile, $bin_data);
$extension = image_type_to_extension(exif_imagetype($tmpfile));
unlink($tmpfile);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62961&edit=1