-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
x/image/webp: WebP decode contrast issue #40173
Comments
/cc @nigeltao |
I'm almost certain this is due to I'm also not sure if image.YCbCr can even handle full range vs limited range YCbCr content. It certainly can't handle any colorspace but BT.601 (which is fine for WebP, which is always BT.601, but won't hold true for newer formats.) |
Is there any temporary hack that can fix this? I'm using python webp library to write the images. |
Out of curiosity, did anyone find a work around for this? Should we just use another webp library? |
Yeah, I ended up using chai2010 webp library. |
@AliFlux thanks ali, appreciate the reply, I’ll try out the library. By the way, the link you gave is broken, I still found the library though. |
Hey guys, I really wanted to highlight that the problem is much worse when there is an image with a white background, for example, the image below: Original: After: I added this because I think it shows the problem more pronounced than the original image submitted by @AliFlux. And also, a big thank you for all the open source work, I really appreciate it and use most of it in my day to day work. Your work obviously has a massive impact on lives around the world. |
It will be looked at (if you expliciltly add me to the PR) but:
|
Awesome, thanks @nigeltao, I appreciate it, I wanted to make sure I didn't spend a bunch of timing creating a solution that has no chance. |
@savtrip are you still working on this issue, because if you aren't I'd be interested in taking over. |
I’m not working on this, I have been too busy, thanks Trent and good luck!
…On Sunday, 28 August 2022, Trent Moyar ***@***.***> wrote:
@savtrip <https://github.com/savtrip> are you still working on this
issue, because if you aren't I'd be interested in taking over.
—
Reply to this email directly, view it on GitHub
<#40173 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKCFL65ZAOWB7YEFIZ33H4LV3JACBANCNFSM4OXVH44Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Is there any update on this? This issue discourages using a technically superior image format (WebP) for users of tools like Hugo that depend on this library because the alternative with the least friction is to go back to jpeg or png. |
The issue with golang's webp implementation is that webp (or more broadly vp8) only encodes and decodes to limited YCbCr using jpeg primaries and matrices, wheras jpeg uses full ycbcr. This means that in order for webp to work, either the go standard library would have to add a new, limited YCbCr type with the proper conversion to RGB, or such a type would have to be added to x/image. This appears to be a substantial amount of work, as the YCbCr type appears in many places, such as this gen.go file. This means that fixing ycbcr in webp also entails rewriting chroma upsampling algorithms. If an instant fix is desired, one option would be to change the webp library to decode to some ycbcrl type, and then users would handle the rgb transform and chroma upsampling. Here is a link to the documented conversion functions in the libwebp source. @nigeltao what are your thoughts? You seem to have written the bulk of the current ycbcr code, so I'm curious if you have any suggestions. I apologize for never getting around to an update. I realized the scale of potentially adding the new limited ycbcr and i set this aside, then difficulties in my life took priority. |
Yeah, the bug is a fair complaint but fixing it properly (in the standard library) is a lot of work (see also my earlier comment) and I don't have the time to do it. You could probably fix it (without touching the standard library) if golang.org/x/image/vp8 decoded directly to an image.RGBA (instead of to an image.YCbCr) or if it had its own FullYCbCr image.Image type. But that's still a substantial change and, again, I don't have the time to do it. Sorry. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I opened up a webp using go, and saved it back to png, The output was different from the source. Other golang webp decoding packages parsed it correctly.
What did you expect to see?
This is the source image, notice the details and the clarity.
What did you see instead?
This is the converted, the details are dimmed, the contrast is lower. Other webp decoding libs maintain the contrast.
The text was updated successfully, but these errors were encountered: