]> granicus.if.org Git - php/commitdiff
Remove channels from getimagesize() results for WebP
authorChristoph M. Becker <cmbecker69@gmx.de>
Sat, 8 Oct 2016 17:34:13 +0000 (19:34 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Sat, 8 Oct 2016 17:47:32 +0000 (19:47 +0200)
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.

ext/standard/image.c
ext/standard/tests/image/getimagesize.phpt

index 994fec106866b2f2d0e3083d282e52c7e931832b..4fb8298f7607cae2c377571b70f69c57eb87b516 100644 (file)
@@ -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;
 }
index 19b355e92e8812387861a7d4a7b4f9e28c2146de..53c6b2a0b6dfcd4e59150311f102e6638daea9ad 100644 (file)
@@ -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"
   }