php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65038 IMAGETYPE_WEBP constant missing
Submitted: 2013-06-14 10:20 UTC Modified: 2016-11-18 10:10 UTC
Votes:17
Avg. Score:4.5 ± 0.7
Reproduced:13 of 14 (92.9%)
Same Version:4 (30.8%)
Same OS:1 (7.7%)
From: david at admin dot amateri dot cz Assigned: cmb (profile)
Status: Closed Package: GetImageSize related
PHP Version: 5.5.0RC3 OS: CentOS 6
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: david at admin dot amateri dot cz
New email:
PHP Version: OS:

 

 [2013-06-14 10:20 UTC] david at admin dot amateri dot cz
Description:
------------
There is no IMAGETYPE_WEBP constant returning from exif_imagetype, but there is webp support since v5.5. You should add it. Thank you.


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-03 14:43 UTC] enumag at gmail dot com
Also webp should be supported by getimagesize, getimagesizefromstring, image_type_to_extension and image_type_to_mime_type.
 [2016-01-15 12:15 UTC] benjamin dot morel at gmail dot com
+1 for WEBP support in getimagesize(), please!

WEBP is becoming increasingly popular, and getimagesize() is so handy to get image information without having to load the whole file using Imagick, for example.
 [2016-06-10 08:13 UTC] archon810 at gmail dot com
I just spent an hour trying to figure out why webp isn't working in getimagesize only to eventually arrive at this bug. Please add support for it.
 [2016-08-03 03:47 UTC] kalle@php.net
-Package: EXIF related +Package: GetImageSize related
 [2016-08-03 03:47 UTC] kalle@php.net
Changing the category here to be "GetImageSize" as internally exif_imagetype() re-uses an internal function we use for GetImageSize(), and exposes it to userland, despite not having anything exif related code in it.
 [2016-09-28 07:44 UTC] sebreghts dot jelle at gmail dot com
This bug report is over 3 years old and webp is gaining traction (http://caniuse.com/#search=webp). Is there any progress on this issue?
 [2016-10-06 17:30 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2016-10-07 22:33 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2016-10-07 22:33 UTC] cmb@php.net
Implemented with <http://git.php.net/?p=php-src.git;a=commit;h=14d4ee93>.
 [2016-10-08 04:56 UTC] enumag at gmail dot com
Why ignore lossless webp? Can you open a new issue about that with an explanation?

Also what exactly does it mean that only lossy webp is supported? Does it mean that if I call getimagesize on a lossless webp it won't return the needed info?
 [2016-10-08 07:32 UTC] cmb@php.net
-Status: Closed +Status: Re-Opened
 [2016-10-08 07:32 UTC] cmb@php.net
> Does it mean that if I call getimagesize on a lossless webp it
> won't return the needed info?

Indeed, getimagesize() would return FALSE in this case.

Actually, I thought that lossless WebP isn't very common and that
it wouldn't be supported by libgd, but at least the latter
assumption was wrong – imagecreatefromwebp() is able to read
lossless WebP (at least the simple format without alpha; haven't
yet checked further). So it makes sense to add support for simple
lossless WebP (VP8L) to getimagesize() and friends.
 [2016-10-08 08:55 UTC] cmb@php.net
-Status: Re-Opened +Status: Closed
 [2016-10-08 08:55 UTC] cmb@php.net
VP8L support implemented with <http://git.php.net/?p=php-src.git;a=commit;h=59cd8eb7>.
 [2016-10-08 09:39 UTC] enumag at gmail dot com
Very nice! :-)

Now is there a reason not to implement VP8X as well? It seems that the "Canvas Width Minus One" and "Canvas Height Minus One" are always at the same position so it should be easy. https://developers.google.com/speed/webp/docs/riff_container#extended_file_format

Of course it depends on whether imagecreatefromwebp supports VP8X or not.
 [2016-10-08 11:33 UTC] cmb@php.net
-Status: Closed +Status: Re-Opened
 [2016-10-08 11:33 UTC] cmb@php.net
> Of course it depends on whether imagecreatefromwebp supports
> VP8X or not.

Not necessarily; for instance, getimagesize() supports BMP, but
GD still doesn't.

Anyhow, as I've just learned imagecreatefromwebp() does support
VP8X (even stored color profiles are applied), so it makes indeed
sense to add support for VP8X to getimagesize().
 [2016-10-08 13:15 UTC] cmb@php.net
-Status: Re-Opened +Status: Closed
 [2016-10-08 13:15 UTC] cmb@php.net
VP8X support added with commit <http://git.php.net/?p=php-src.git;a=commit;h=1d977e55>.
 [2016-11-17 22:57 UTC] bluespire at gmail dot com
Is there any chance this patch would be accepted into the 5.6 branch?

Not all of us are able to move directly to 7.1 to take advantage of this, and other webp supporting functions like imagecreatewebp are in 5.5+
 [2016-11-18 10:10 UTC] cmb@php.net
> Is there any chance this patch would be accepted into the 5.6
> branch?

This ticket had been rightly filed as feature request, and we
usually don't add new features to stable branches for QA reasons.
Note also that active support for PHP 5.6 ends in about 6 weeks,
so it's rather unlikely that this patch will be backported to 5.6.

If you really have to stick with PHP 5.6 for now, consider a
userland implementation. If you only have to detect whether a file
is in WebP format, it should be sufficient to check whether the
first three bytes of the file are `VP8`.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Oct 01 20:05:53 2022 UTC