[php-src] Issue #20201: AVIF images misdetected as HEIF after introducing HEIF support in GD

From: Date: Fri, 17 Oct 2025 11:48:40 +0000
Subject: [php-src] Issue #20201: AVIF images misdetected as HEIF after introducing HEIF support in GD
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251078@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/20201 Author: andypost ### Description After commit https://github.com/php/php-src/commit/dfac2da7fba930570fcda99205cfcf53db PHP incorrectly detects certain AVIF files as HEIF. The issue arises because both formats use the same ISOBMFF (.heif) container and share the mif1 major brand. Current PHP logic checks only the major_brand and stops, even when the compatible_brands list includes avif. Example test file header: ``` size: 0x0000001C boxtype: 'ftyp' major_brand: 'mif1' minor_version: 0 compatible_brands: ['mif1', 'avif', 'miaf'] ``` PHP currently classifies this as IMAGE_FILETYPE_HEIF, though it is an AVIF image. **Expected result:** Files that include 'avif' in compatible_brands should be recognized as IMAGE_FILETYPE_AVIF. **Actual result:** They are recognized as IMAGE_FILETYPE_HEIF. Environment: ``` - PHP 8.3.x / 8.4.x - GD enabled (bundled) - libavif < 1.2.0 (no experimental HEIF support) - Ubuntu Noble / Debian Testing ``` ```php $file = 'test.avif'; $info = getimagesize($file); var_dump($info[2]); // Expected IMAGETYPE_AVIF, got IMAGETYPE_HEIF ``` before 8.5 it returns int(19) but on 8.5 int(20) Possible fix: When parsing ftyp, prefer avif if it appears in compatible_brands, or parse all compatible brands before deciding on type. Related references: - https://github.com/php/php-src/commit/dfac2da7fba930570fcda99205cfcf53db - https://github.com/nokiatech/heif/issues/74 ### PHP Version ```plain PHP 8.5.0RC2 (cli) (built: Oct 8 2025 09:46:31) (NTS) Copyright (c) The PHP Group Built by Alpine Linux aports Zend Engine v4.5.0RC2, Copyright (c) Zend Technologies with Zend OPcache v8.5.0RC2, Copyright (c), by Zend Technologies ``` ### Operating System Ubuntu

« previous php.bugs (#251078) next »