Exif Read Data - file not supported

Error log is filling up with the following message in MODX 3.0.3 and PHP 8.1…

[2023-03-24 11:33:37] (ERROR @ /var/www/vhosts/hos-tingdotcom/httpdocs/core/src/Revolution/Sources/modMediaSource.php : 2242) PHP warning: exif_read_data(my-image-name.png): File not supported
2 Likes

Same thing happening for me, with same versions.
It doesn’t happen with all images, in my case the problem was with an old PNG, created with Adobe ImageReady (or at least that’s what was in meta).

1 Like

Have you guys implemented a solution at all ?

It’s happening to me too, on .webp images and the occasional .png as well.

I think I will need to fix it (even if it’s a hack) as I can’t allow the logs to get too bloated…

if you are asking for a solution, not to fill the the error log, you can try to set the systemsettings
log_level and debug to 0

1 Like

Thank you but I’d like to know if anyone has a solution to fix the actual error?

It’s not really an error, just a warning that gets logged.
It occurs here in the code:

Theoretically, the @ (the error control operator) in front of the function should suppress any errors.


You could add an if statement to the code, to only run exif_read_data for certain image types. There exists a variable $ext with the image extension.

A custom error handler could filter out these error messages, but it seems like overkill for the issue.

The logo for the CustomSearch extra causes this error message every time the page is loaded, yet the image looks fine. Is there some good reason that MODX is pulling exif information for every image, even though it’s likely that some images will cause this error message?

1 Like

3.0.4.
The same problem. PHP warning: exif_read_data

It’s happening for me too…

It’s not just with old images. PNGs generated with current versions of Photoshop and Affinity software produce the same error. Images displayed on the front end don’t generate the error for me; it seems confined to viewing images in the Media Manager.

This would eliminate the error message for .png files, but I suspect it might cause other errors without some other changes to the code.:

if (strpos($absolute_path, '.png') === false) {
     $exif = @exif_read_data($absolute_path);
}

Has anyone figured out what’s causing this?

2 Likes

I’m having this same issue on 3.0.5-pl. I’m using a lot of .webp images and every visit to the media browser generates a few dozen errors in the log. How do I suppress these? The log is filling up and it makes it hard to find errors I should actually be paying attention to.

You can modify the media source class file if you don’t need exif data.

The file is core/src/Revolution/Sources /modMediaSource.php.

Around line 2260.

If you add false && to the beginning of the line above, the exif code will never run and the errors should stop.

if (false && function_exists('exif_read_data')) {

I see there’s an error suppression @ sign in the code, which should suppress the error, but it’s been there for three years so it’s clearly not working.

I’m not sure what the side effects of the fix would be, but it seems likely that the height, width, and orientation are already correct at that point, so it should have no effect. I could be wrong.

Thanks Bob, when I try to edit that file I get an error: File extension php is not permitted.

I’m sure there’s a work around, just not sure what it is. This is a MODX Cloud site.

Also, if I do manage to save the edits will this be overwritten on next update?

Check the upload_files System Setting. Adding php, to the beginning of the list should make it editable.

I created a pull request on Github, that hopefully finally fixes this issue:

1 Like