summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2016-10-08 19:34:13 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2016-10-08 19:47:32 +0200
commited282f110bcabb62579769c1860c615b5beab6da (patch)
tree0f05dacae136ae5387d52c5b25b9e8e654de73ba
parentc43a54e4fe88b61497667d63049af3e5c5b70a59 (diff)
downloadphp-git-ed282f110bcabb62579769c1860c615b5beab6da.tar.gz
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.
-rw-r--r--ext/standard/image.c12
-rw-r--r--ext/standard/tests/image/getimagesize.phpt8
2 files changed, 4 insertions, 16 deletions
diff --git a/ext/standard/image.c b/ext/standard/image.c
index 994fec1068..4fb8298f76 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 19b355e92e..53c6b2a0b6 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"
}