com php-src: Remove channels from getimagesize() results for WebP: ext/standard/image.c ext/standard/tests/image/getimagesize.phpt
| From: | Christoph Michael Becker | Date: | Sat, 08 Oct 2016 17:47:32 +0000 |
| Subject: | com php-src: Remove channels from getimagesize() results for WebP: ext/standard/image.c ext/standard/tests/image/getimagesize.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94873@lists.php.net to get a copy of this message | ||
Commit: ed282f110bcabb62579769c1860c615b5beab6da
Author: Christoph M. Becker <cmbecker69@gmx.de> Sat, 8 Oct 2016 19:34:13 +0200
Parents: c43a54e4fe88b61497667d63049af3e5c5b70a59
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ed282f110bcabb62579769c1860c615b5beab6da
Log:
Remove channels from getimagesize() results for WebP
Both lossless and lossy WebP can have an alpha channel, but this is
somewhat hard to detect. Furthermore, it is not clear whether an alpha
channel should be counted for getimagesize(). Therefore we remove the
channel element from the result array.
Changed paths:
M ext/standard/image.c
M ext/standard/tests/image/getimagesize.phpt
Diff:
diff --git a/ext/standard/image.c b/ext/standard/image.c
index 994fec1..4fb8298 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -1151,8 +1151,8 @@ static struct gfxinfo *php_handle_webp(php_stream * stream)
switch (format) {
case ' ':
- result->width = (buf[14]) + ((buf[15] & 0x3F) << 8);
- result->height = (buf[16]) + ((buf[17] & 0x3F) << 8);
+ result->width = buf[14] + ((buf[15] & 0x3F) << 8);
+ result->height = buf[16] + ((buf[17] & 0x3F) << 8);
break;
case 'L':
result->width = buf[9] + ((buf[10] & 0x3F) << 8) + 1;
@@ -1164,14 +1164,6 @@ static struct gfxinfo *php_handle_webp(php_stream * stream)
break;
}
result->bits = 8; /* always 1 byte */
- switch (format) {
- case ' ':
- result->channels = 3; /* always YUV */
- break;
- case 'L':
- result->channels = 4; /* always ARGB */
- break;
- }
return result;
}
diff --git a/ext/standard/tests/image/getimagesize.phpt b/ext/standard/tests/image/getimagesize.phpt
index 19b355e..53c6b2a 100644
--- a/ext/standard/tests/image/getimagesize.phpt
+++ b/ext/standard/tests/image/getimagesize.phpt
@@ -153,7 +153,7 @@ array(16) {
string(9) "image/gif"
}
["test3llpix.webp"]=>
- array(7) {
+ array(6) {
[0]=>
int(1)
[1]=>
@@ -164,13 +164,11 @@ array(16) {
string(20) "width="1" height="3""
["bits"]=>
int(8)
- ["channels"]=>
- int(4)
["mime"]=>
string(10) "image/webp"
}
["test3pix.webp"]=>
- array(7) {
+ array(6) {
[0]=>
int(1)
[1]=>
@@ -181,8 +179,6 @@ array(16) {
string(20) "width="1" height="3""
["bits"]=>
int(8)
- ["channels"]=>
- int(3)
["mime"]=>
string(10) "image/webp"
}