Skip to content
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

Transparent PNG's loses transparency with the Modern Image Formats #1576

Open
callievg opened this issue Oct 3, 2024 · 12 comments
Open

Transparent PNG's loses transparency with the Modern Image Formats #1576

callievg opened this issue Oct 3, 2024 · 12 comments
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Bug An existing feature is broken

Comments

@callievg
Copy link

callievg commented Oct 3, 2024

Bug Description

I tried the modern image formats plugin and when it converts my transparent png's to Exif AVIF it loses transparency. There should be a way to exclude transparent PNGs?

Steps to reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Screenshots

Additional Context

  • PHP Version:
  • OS: [e.g. iOS]
  • Browser: [e.g. chrome, safari]
  • Plugin Version: [e.g. 22]
  • Device: [e.g. iPhone6]
@callievg callievg added the [Type] Bug An existing feature is broken label Oct 3, 2024
@github-project-automation github-project-automation bot moved this to Not Started/Backlog 📆 in WP Performance 2024 Oct 3, 2024
@westonruter
Copy link
Member

@callievg By Exif do you mean AVIF?

@adamsilverstein Does GD or Imagick not support transparency when generating AVIF perhaps?

@callievg
Copy link
Author

callievg commented Oct 3, 2024

@westonruter Sorry Yes AVIF

@westonruter
Copy link
Member

@callievg Can you share your Site Health information? Specifically the Media Handling section. We should capture the specific versions of GD and ImageMagick that you have on your server.

@westonruter westonruter added the [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) label Oct 9, 2024
@westonruter
Copy link
Member

@callievg Here's some info on how to access your Site Health info: https://yoast.com/wordpress-site-health/

Specifically, then Info tab includes a Media Handling section like this:

Image

You can also copy the text via the "Copy site info to clipboard" button.

@callievg
Copy link
Author

callievg commented Oct 9, 2024

screencapture-innovationsoftheworld-wp-admin-site-health-php-2024-10-09-09_49_24.pdf

Image

Here you go!

Apologies - I missed your last message.

@westonruter
Copy link
Member

OK, I am able to reproduce this issue even in the plugin's wp-env development environment. Specifically, this happens only with AVIF. When I am converting to WebP, then the transparency is preserved.

@adamsilverstein Do we need to have PNGs only convert to WebP for now?

@pbearne
Copy link
Contributor

pbearne commented Oct 10, 2024

or check for transparency

@adamsilverstein
Copy link
Member

@adamsilverstein Do we need to have PNGs only convert to WebP for now?

Only if we can't find a fix for the issue. I believe we tested for avif transparency

or check for transparency

We do directly check for transparency and try to apply that to output images for uploaded transparent images, see https://github.com/WordPress/wordpress-develop/blob/b5df5f08e0a43a05a2a52b5c151028e0c6a6d14d/src/wp-includes/class-wp-image-editor-imagick.php#L480-L494. maybe something is off with this logic.

I will give this a test locally to see if I can reproduce. if possible, please share the image(s) you are using to test.

@adamsilverstein
Copy link
Member

Here you go!

@callievg Thanks for the details. It looks like your Imagick should be able to output AVIF images with transparencies.

I'm curious if you can test a couple of things:

  • can you test uploading a transparent avif and verify the subsized/thumbnail images are also transparent? You can use this image from core for testing.
  • Under settings->media change this output format to WebP. Are the output files correctly transparent?

@adamsilverstein
Copy link
Member

This worked fine in my testing, I uploaded a PNG with transparency and all of the output AVIF images were also transparent background images, they looked just like the original. Here is the test image I used:

Image

Here is my media info:

Image

This may not be version specific, the doc block in core says:

Note that Imagick::getImageAlphaChannel() is only available if Imagick has been compiled against ImageMagick version 6.4.0 or newer.

@adamsilverstein Do we need to have PNGs only convert to WebP for now?

Maybe we can use the check from core and fallback to WebP if the upload has transparency, and the output format is AVIF, and Imagick is the editor and doesn't have support for transparency (ie. getImageAlphaChannel not defined).

@westonruter
Copy link
Member

Report from a user on the support forum: https://wordpress.org/support/topic/avif-not-supporting-transparent-png/

@alexfacciorusso
Copy link

This affects me too. Using your latest (current) wordpress:php8.3-fpm docker image, and served through apache on a separate container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Bug An existing feature is broken
Projects
Status: Not Started/Backlog 📆
Development

No branches or pull requests

5 participants