Expose near lossless WebP encoding#67918
Expose near lossless WebP encoding#67918DeeJayLSP wants to merge 1 commit intogodotengine:masterfrom
Conversation
|
Out of curiosity, how does Near Lossless differ from |
It doesn't. Near Lossless at 100 is true lossless. Maybe you meant Lossy quality 100? Lossy encodes images using YUV420, while Near Lossless and Lossless use RGB. That's the main difference. |
1a40707 to
feb86d1
Compare
feb86d1 to
ce66ed6
Compare
|
I meant Lossy indeed.
I see, that makes sense. I've used lossy quality 100 for godot-docs images that were too large to use lossless compression, and it still looks pretty good while having file sizes smaller than JPEGs with lower quality. |
|
Despite the fact it works, I didn't like how messy the code came out. May do a complete refactor later by using helper functions that will likely reduce diff. |
ce66ed6 to
ae547d6
Compare
|
Refactor done. The main functionality of the webp lossless function was turned into a helper function, while the original calls this helper by providing a near lossless value of 1.0 (actually lossless). The lossy function, that previously called the modified lossless function, now calls the helper. Everything that was changed to match the new lossless function was reverted. |
ae547d6 to
79e0a58
Compare
fire
left a comment
There was a problem hiding this comment.
Looks good.
As per custom:
- needs a contributor review
- needs style and architecture review
79e0a58 to
7a3ffb8
Compare
|
I have changed the helper function a bit to better match my follow-up PR.
|
|
This PR will be on wait for #67948 (and maybe some changes by reduz) to be done, as it's better to be done on top of it. |
stale, OP has further plans for PR
Bugsquad edit removed, as it is now invalid.
I still intend to use this PR for the implementation, so I ask to keep it open.
Adds a checkable option to texture importers called Near Lossless, when Mode is set to Lossy:
It also affects other Lossy importers:
When checked, importing will use the same workflow as Lossless, but the value of Lossy Quality will be passed to
config.near_lossless, which decreases image quality in order to reduce its size (while keeping RGB(A) color space instead of using lossy's YUV(A)420) when below 100. This is a built-in feature in libwebp.A few things to note:
config.near_lossless' default is 100) or the image being imported is too simple.