-
Notifications
You must be signed in to change notification settings - Fork 107
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
PNG conversion to AVIF / WebP does not work reliably #1798
Comments
@adamsilverstein Any idea what might be going on here? |
Could it possibly be related to the PNG itself? ie. does one PNG consistently fail to generate sub sizes while another consistently works? Can you check server logs and the browser console log for any potential errors? I can give this a test to see if I can reproduce on my end |
@adamsilverstein I can confirm it always happens with specific PNG images, but not others. So there has to be something maybe in the different PNG encodings that makes my server not want to deal with some of them. There are no errors or Console logs when uploading them. So the problem isn't flagged, it's "silently" failing. When I try to open the full size image (for one of the PNG uploads where the problem occurs), I just get a 404. |
Could be related to alpha channel presence, transparency or bit depth. Can you share your site health->info->media details so we can see what version GD/Imagick you are using? If possible, can you share a working and non-working image? these would be useful for a unit test to reproduce the issue. We recently landed some PNG handling improvements in core that could help, if possible can you try agains trunk? |
Possibly your generated images are larger that the original and so is being discarded in Do you have the "Also generate fallback images in the original upload format" option enabled under settings->media? If so, try disabling that to see if generation works for all images. If you want both images always, you can disable the deletion behavior with:
|
Here's my Site Health info for media:
It looks like my site's Imagemagick version does not support AVIF, but GD does, so I assume my site attempts to use GD for AVIF. |
That option is turned off on my site, so I have the problem even with the (technically much simpler) setup of only mapping the output format. |
This might be related to a GD "false positive" issue, see https://core.trac.wordpress.org/ticket/60628 which mentions zero sized image failures for some GD versions (although its odd that some sizes work). Can you try to determine your PHP / GD versions and maybe see if you are able to get them upgraded or get imagick installed by your host? |
Aside: Since the PNG to AVIF generation only fails for the original image, but not the thumbnail, I wonder whether any of the additional processing of the sub-sizes (e.g. scaling down the image) alters something in the PNG file already, which then makes the conversion to AVIF work. Since only the originally uploaded image is failing to convert to AVIF (which of course is completely outside of WordPress's control in terms of how it's encoded etc.), I wonder whether it would work if we first did some other (temporary) processing to that image before saving it as AVIF. |
Maybe - we can certainly try retracing the calls more carefully and trying to reproduce. One thing I noticed is we do call resize on the image, but the image dimensions match those of the original, so that call returns early (this conditional returns true). We could try calling with a slightly different size to test. |
Bug Description
When I uploaded a PNG to my website in the block editor, I ran into a problem where the image file would not be found. As the file was (supposed to be) transformed to AVIF, I suspected it might have something to do with the Modern Image Formats plugin. Indeed that appears to be the case.
Some more details on what I am experiencing:
{orig-name}-150x150.avif
was successfully generated. But the main attachment file{orig-name}-png.avif
is not to be found.There is a chance this has to do with certain server support / configuration, but in any case we should try to figure it out since we shouldn't offer transforming to AVIF in situations where it's not reliable.
Possibly caused by addition of PNG support which was done via #371. I don't have any problems with transforming JPEG into AVIF or WebP, the problems only occur with PNG files.
Steps to reproduce
Additional Context
The text was updated successfully, but these errors were encountered: