-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exif_read_data does not support PNG metadata despite PNG supporting chunks #18162
Comments
Hi @IlyasMohetna, it is because libexif itself does not support the PNG format, it adheres to exif up to (some of) 2.3.x specs but still no direct support for PNG. Would PECL imagemagick fits the bill in your case ? |
Hi @devnexen , thanks for your quick reply! I understand now since libexif doesn’t support PNG, the exif_read_data() function also can’t handle it. I was hoping it could work with PNG directly, but it makes sense if the library doesn’t support that format. About PECL imagick: yes, it could work, and it supports more formats, but it adds a larger dependency. For simple projects where we just need to read some basic metadata, it seems a little bit overkill for my use case. Do you think it’s possible for PHP to support reading PNG metadata (like tEXt, iTXt, or zTXt) in the future maybe as part of the exif extension or a new function? This wouldn’t need full EXIF support, just reading standard metadata fields that PNG files already support. |
It might be possible but not as straightforward, e.g. we would need zlib to decompress zTXt, we would need to handle endianess ... I do not have any idea how hard it would be without dependency but zlib, it is usually preferable to rely on specialised library (e.g. libpng). |
I might recommend to write to internal mailing list, whether it s to bring points I did not think about, feasibility or if it is relevant to have it in std php to begin with. |
Description
The exif_read_data() function in PHP currently supports reading metadata only from JPEG and TIFF images. However, the PNG format officially supports metadata through standardized chunks (e.g., tEXt, iTXt, zTXt), yet this function does not support PNG files.
Expected Behavior
Since PNG has a structured way to embed metadata, I expected exif_read_data() to parse and return data from those chunks similarly to how it does for JPEG EXIF headers.
Actual Behavior
Attempting to use exif_read_data() on a PNG file returns false and throws a warning that the file format is unsupported.
Question
Is there a reason this functionality is limited to JPEG/TIFF? Could native support for PNG metadata be considered for inclusion in PHP without relying on external libraries or userland workarounds?
Use Case
Having native support for PNG metadata would simplify workflows involving image processing or archival, where JPEG is not the preferred format due to compression loss.
Environment
PHP Version: 8.2
OS: Ubuntu 22.04
The text was updated successfully, but these errors were encountered: