You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
exif_read_data() reports "Invalid WebP file" for a valid WebP without an EXIF chunk #25678
exif_read_data() on a well formed WebP file that has no EXIF chunk emits a warning and returns false. A JPEG without EXIF returns the FILE and COMPUTED sections and no warning.
Warning: exif_read_data(): Invalid WebP file in ... on line ...
bool(false)
Expected: FILE and COMPUTED sections with MimeTypeimage/webp, as for the JPEG (["FILE", "COMPUTED"]). Truncated or oversized chunks should keep returning false.
exif_scan_WEBP_header() returns false when it reaches the end of the chunk list without finding an EXIF chunk. I found it on PHP-8.6 at 1be37f6 while checking WebP metadata handling for WordPress uploads. WordPress suppresses the warning, but other callers will log it.
PHP Version: PHP-8.6 branch (also master)
Operating System: Ubuntu 24.04 (WSL2), x86-64
Disclosure: I used an LLM to help investigate this and to draft this report. I reviewed the reproduction and results myself.
Just noting that the same is true for HEIF files as well.
If a warning is desired, then JPEG and TIFF should also be changed for consistency. However, I think it makes more sense for invalid file warnings to only be triggered when a file is actually malformed/invalid.
Thanks @desrosj, I checked HEIF and you are right, it behaves the same way. On the PHP-8.6 branch tip (1be37f6, NTS, Linux x86-64 under WSL2) I took ext/exif/tests/image029.heic, which parses normally (53 keys), and changed the infe entry for its Exif item to a different four-character item type. That leaves a well-formed HEIC with no Exif item. exif_read_data() then emits Warning: exif_read_data(): Invalid HEIF file and returns false.
The cause looks like the WebP one. exif_scan_HEIF_header() returns true only after an Exif item has been found and read, so a file with no Exif item falls through to return false and the caller reports "Invalid HEIF file". For comparison, a JPEG with a scan header and no EXIF data, and a TIFF with an empty IFD, both return an array of 7 keys with no warning on the same build.
I agree that the warning should be kept for files that are actually malformed. For HEIF, exif_isobmff_parse_meta() returns nothing and stops silently on truncated data, so the scanner cannot currently tell "no Exif item" from "damaged meta box". A fix would need that function to report which case it hit. I have not written one, and PR #25679 only changes WebP.
Caveat: the test file is a real HEIC with one item retyped, not an untouched file from a camera or phone. I have not tested AVIF or any other ISO base media file.
Disclosure: I used an LLM to help run these checks and to draft this comment. I reviewed the results before posting.
Activity
desrosj commentedon Nov 23, 2026
Just noting that the same is true for HEIF files as well.
If a warning is desired, then JPEG and TIFF should also be changed for consistency. However, I think it makes more sense for invalid file warnings to only be triggered when a file is actually malformed/invalid.
AceMedia commentedon Nov 23, 2026
Thanks @desrosj, I checked HEIF and you are right, it behaves the same way. On the PHP-8.6 branch tip (1be37f6, NTS, Linux x86-64 under WSL2) I took
ext/exif/tests/image029.heic, which parses normally (53 keys), and changed theinfeentry for its Exif item to a different four-character item type. That leaves a well-formed HEIC with no Exif item.exif_read_data()then emitsWarning: exif_read_data(): Invalid HEIF fileand returnsfalse.The cause looks like the WebP one.
exif_scan_HEIF_header()returnstrueonly after an Exif item has been found and read, so a file with no Exif item falls through toreturn falseand the caller reports "Invalid HEIF file". For comparison, a JPEG with a scan header and no EXIF data, and a TIFF with an empty IFD, both return an array of 7 keys with no warning on the same build.I agree that the warning should be kept for files that are actually malformed. For HEIF,
exif_isobmff_parse_meta()returns nothing and stops silently on truncated data, so the scanner cannot currently tell "no Exif item" from "damaged meta box". A fix would need that function to report which case it hit. I have not written one, and PR #25679 only changes WebP.Caveat: the test file is a real HEIC with one item retyped, not an untouched file from a camera or phone. I have not tested AVIF or any other ISO base media file.