Resized webp images are dimmed a bit

Resized webp images are dimmed a bit. Is there any way to avoid it?

Set quality to 100 if you want the same quality as original image.

image is still dimmed even with 100 quality

Maybe try the fill, fit or crop filters. Otherwise, wait for someone more experienced to answer you. Personally, using fill with quality 100 solved the blurriness for me.

Also check this if that doesn’t work.

https://github.com/gohugoio/hugo/issues/8879

If someone can confirm that proof of concept: Encode and Decode using the libwebp library via WASM by bep · Pull Request #14234 · gohugoio/hugo · GitHub fixes this, I may find motivation to get that properly done (the link is just a proof of concept and not ready for prime time). Note that my primary motivation is not “dimmed images”, but to get rid of Hugo’s extended build (which requires a host specific C/C++ chain, a pain to maintain).

This doesn’t seem to resolve the WebP decode contrast issue, but perhaps I’m doing something wrong:

git clone --single-branch -b hugo-github-issue-14234 https://github.com/jmooring/hugo-testing hugo-github-issue-14234
cd hugo-github-issue-14234
hugo server

hugo v0.153.0-DEV-f738a82b6c9f0f49b76cd4ce7e638997b695f87a+extended+withdeploy linux/amd64

Using this command to convert the WebP to JPEG works as expected (no contrast problem):

dwebp test.webp -o test.jpg

In addition to the test image above, this test site contains 20 WebP images (1920x1080), converted to JPEG 300 px wide. I used this command to compare build times:

rm -rf public/ resources/ && time hugo

The build time for v0.152.2 was about 1.3 seconds. With the WASM approach the build time increased to about 1.7 seconds.

Yea, it currently is single-threaded, so there may be some room for improvements, but there will be some performance penalty.

Thanks for the test case, I will have another look.

@jmooring I have pushed a fix for the above – I read this again, and now I understood it … x/image/webp: WebP decode contrast issue · Issue #40173 · golang/go · GitHub

https://github.com/gohugoio/hugo/pull/14234 is still at f738a82.

OK, pushed (and retested). Let’s continue this discussion in proof of concept: Encode and Decode using the libwebp library via WASM by bep · Pull Request #14234 · gohugoio/hugo · GitHub

OK, both me and @jmooring have tested and confirmed the “proof of concept”. I will make it into something shippable and get it into Hugo 0.153.0 that’s coming very soon (well before xmas).

2 Likes