Bug #81265 [Opn->Csd]: getimagesize returns 0 for 256px ICO images
| From: | git@php.net | Date: | Fri, 16 Jul 2021 08:08:44 +0000 |
| Subject: | Bug #81265 [Opn->Csd]: getimagesize returns 0 for 256px ICO images | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235076@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81265&edit=1
ID: 81265
Updated by: git@php.net
Reported by: george at dietrich dot app
Summary: getimagesize returns 0 for 256px ICO images
-Status: Open
+Status: Closed
Type: Bug
Package: GetImageSize related
Operating System: All
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of Blacksmoke16 (author) and nikic (committer)
Revision: https://github.com/php/php-src/commit/8f97f82e356f2410f7f6fff3ed6fe3e51709ff6c
Log: Fix bug #81265: getimagesize returns 0 for 256px ICO images
Previous Comments:
------------------------------------------------------------------------
[2021-07-16 01:06:00] george at dietrich dot app
The following pull request has been associated:
Patch Name: Fix bug 81265: Set ICO height/width to 256 if 0
On GitHub: https://github.com/php/php-src/pull/7247
Patch: https://github.com/php/php-src/pull/7247.patch
------------------------------------------------------------------------
[2021-07-16 00:40:11] george at dietrich dot app
Description:
------------
Using getimagesize on a .ico file that is 256px wide or 256px high will result in that value being
returned at 0 due to the value being stored as 0 in the header as per https://devblogs.microsoft.com/oldnewthing/20101022-00/?p=12473
and https://en.wikipedia.org/wiki/ICO_(file_format):
> The value 0 is accepted as representing a width or height of 256.
> Can be any number between 0 and 255. Value 0 means 256 pixels.
Wasn't sure what version to pick as the bug is like 14 years old (introduced via https://github.com/php/php-src/commit/c76e8e03a1cc67d695b1fa024924a462ca897434),
so I just with with irrelevant as it's been an issue since 5.3.0.
Test script:
---------------
var_dump(getimagesize("https://raw.githubusercontent.com/toy/image_size/master/spec/images/ico/32x256.ico"));
Expected result:
----------------
array(6) {
[0]=> int(32)
[1]=> int(256)
[2]=> int(17)
[3]=> string(21) "width="32" height="256""
["bits"]=> int(8)
["mime"]=> string(24) "image/vnd.microsoft.icon"
}
Actual result:
--------------
array(6) {
[0]=> int(32)
[1]=> int(0)
[2]=> int(17)
[3]=> string(21) "width="32" height="0""
["bits"]=> int(8)
["mime"]=> string(24) "image/vnd.microsoft.icon"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81265&edit=1