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
Webp image with alpha channel is converted to jpeg image that has a black color for the alpha instead of being a transparent png #35674
Comments
Did anyone have a chance to look at this? |
Probably related issue here but I see the same problem with PNGs instead of WEBPs |
I'm trying to install next locally with yarn to try and create a PR, but so far I've been facing errors during the installation of next.js locally. |
I have created PR #36611 that fixes this issue. @balazsorban44 I see that you were the one to mark this as a bug and put the label "area: next/image". Can you do a review of the PR? |
I have the same issue, but is it normal that when testing on a local build or dev the same images are rendering properly ? |
@macojaune It could be because you didn't remove/delete the |
I’ve observed the same behaviour. To reproduce you can also use Firefox with the Don't "Accept" image/webP extension. |
Wait, what? Why would someone want to not accept WebP images? |
I meant this only for testing purposes: instead of using an older browser which doesn’t support webp (or BrowserStack), you can also use Firefox with this plugin. |
In my case I can reproduce the issue when Accept request header is removed (we can do it with an extension). Some CDNs like Azure Front Door send traffic without this header and cache an image with black background |
I have been experiencing this problem. While the vast majority of real users use browsers with WebP support, the same is not the case with crawlers. While the latter indexes the site, images with transparency are cached with a black background when converted to JPEG. |
Verify canary release
Provide environment information
What browser are you using? (if relevant)
Safari 13.1 (on macOS Catalina) through BrowserStack
How are you deploying your application? (if relevant)
next start, Vercel
Describe the Bug
After the implementation of the next/image webp convertion in
next@12.1.1
(see #20794 and #35190), I decided to give it a go, because I was using a workaround for browsers that didn't support the WEBP format. For those wondering - I just had a handler that would load the appropriate jpg or png if there is an error loading the webp image.Anyway, I removed my workaround and left only the webp image without the error handling logic. I had to test it on a browser that didn't support WEBP format images. One such browser is Safari - version 13.1, which I was able to test through BrowserStack on macOS Catalina. On our company's website we serve different webp images - some of them are pure JPGs without any alpha and they were converted and served on Safari 13.1 without a problem. However, we also have a lot of WEBP images that have an alpha channel, meaning that their converted counterparts are PNGs. I was disappointed to find out that those converted WEBP images did not account for the alpha in the image. Instead, the alpha is being substituted with a black color / black background. Here are images from Chrome and Safari 13.1, so that you can get a better understanding:
Chrome
Safar 13.1
Given this issue, I am not able to update the version of
next
, so basically I am stuck with version12.1.0
until this has been fixed.Expected Behavior
I expect the WEBP image that has an alpha channel to be converted to its PNG counterpart, instead of being converted to a JPG image that has black for the alpha parts of the image.
To Reproduce
.webp
extension to the public directorynext/image
Image
component and pass that imported image as asrc
prop.The text was updated successfully, but these errors were encountered: