[php-src] Issue #21242: `getimagesizefromstring()` with AVIF image returns false sometimes
| From: | carestad | Date: | Tue, 17 Feb 2026 12:55:08 +0000 |
| Subject: | [php-src] Issue #21242: `getimagesizefromstring()` with AVIF image returns false sometimes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251693@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/21242
Author: carestad
### Description
The following code:
```php
<?php
var_dump(getimagesizefromstring(Http::withHeader('accept',
'image/avif')->get('https://www.ikea.com/no/no/images/products/alvine-spets-lette-gardiner-1-par-offwhite-med-stanglomme__0099780_pe242082_s5.jpg')->body()));
```
_(Using the Laravel Http facade here to simplify setting the
accept header to
image/avif since IKEA serves images based on what browsers prefer)_
Resulted in this output:
```
false
```
But I expected this output instead:
```
[
0 => 1400,
1 => 1400,
2 => 2,
3 => "width="1400" height="1400"",
"bits" => 8,
"channels" => 3,
"mime" => "image/avif",
"width_unit" => "px",
"height_unit" => "px",
]
```
This does not seem to work in 8.4.18 nor 8.5.3. I have not tried older versions in 8.3 or 8.2
though.
This has been tested on a docker container where GD is compiled like this:
```
FROM php:8.5.3-alpine3.23
RUN apk add --no-cache \
$PHPIZE_DEPS \
bash \
git \
freetype-dev \
libjpeg-turbo-dev \
libwebp-dev \
libpng-dev \
libavif-dev \
zip \
unzip \
libzip-dev \
bind-tools \
libpq-dev \
linux-headers \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-avif \
&& docker-php-ext-install -j$(nproc) \
gd exif bcmath pcntl pdo_pgsql zip sockets
```
Other AVIF images like [this
one](https://raw.githubusercontent.com/test-images/avif/refs/heads/main/202105/squoosh/losssless7/cs-gray-7f7f7f.avif)
works well, so I assume this only applies to certain AVIF encoded images.
### PHP Version
```plain
8.5.3
More info from phpinfo():
PHP Version => 8.5.3
System => Linux 46fecb3a11d1 6.18.7-061807-generic #202601231045 SMP PREEMPT_DYNAMIC Fri Jan 23
11:25:00 UTC 2026 x86_64
Build Date => Feb 13 2026 18:34:10
Build System => Linux - Docker
Build Provider => https://github.com/docker-library/php
Configure Command => './configure' '--build=x86_64-linux-musl'
'--sysconfdir=/usr/local/etc' '--with-config-file-path=/usr/local/etc/php'
'--with-config-file-scan-dir=/usr/local/etc/php/conf.d'
'--enable-option-checking=fatal' '--with-mhash' '--with-pic'
'--enable-mbstring' '--enable-mysqlnd' '--with-password-argon2'
'--with-sodium=shared' '--with-pdo-sqlite=/usr' '--with-sqlite3=/usr'
'--with-curl' '--with-iconv=/usr' '--with-openssl'
'--with-readline' '--with-zlib' '--enable-phpdbg'
'--enable-phpdbg-readline' '--with-pear'
'build_alias=x86_64-linux-musl' 'PHP_UNAME=Linux - Docker'
'PHP_BUILD_PROVIDER=https://github.com/docker-library/php'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/etc/php
Loaded Configuration File => (none)
Scan this dir for additional .ini files => /usr/local/etc/php/conf.d
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini,
/usr/local/etc/php/conf.d/docker-php-ext-exif.ini,
/usr/local/etc/php/conf.d/docker-php-ext-gd.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini,
/usr/local/etc/php/conf.d/docker-php-ext-sockets.ini,
/usr/local/etc/php/conf.d/docker-php-ext-sodium.ini,
/usr/local/etc/php/conf.d/docker-php-ext-zip.ini,
/usr/local/etc/php/conf.d/docker-php.ini
PHP API => 20250925
PHP Extension => 20250925
Zend Extension => 420250925
Zend Extension Build => API420250925,NTS
PHP Extension Build => API20250925,NTS
PHP Integer Size => 64 bits
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => enabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
Zend Max Execution Timers => disabled
IPv6 Support => enabled
DTrace Support => disabled
Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2,
tlsv1.3
Registered Stream Filters => zlib.*, convert.iconv.*, string.rot13, string.toupper,
string.tolower, convert.*, consumed, dechunk
(...)
gd
GD Support => enabled
GD Version => bundled (2.1.0 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.14.1
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 8
PNG Support => enabled
libPNG Version => 1.6.54
WBMP Support => enabled
XBM Support => enabled
WebP Support => enabled
BMP Support => enabled
AVIF Support => enabled
TGA Read Support => enabled
```
### Operating System
Alpine 3.23.3