From: Christoph M. Becker Date: Sat, 8 Oct 2016 17:34:13 +0000 (+0200) Subject: Remove channels from getimagesize() results for WebP X-Git-Tag: php-7.1.0RC4~75 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed282f110bcabb62579769c1860c615b5beab6da;p=php 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. --- 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" }