Skip to content

WebP quality and hint parameters ignored since v0.153.0 #14316

@simonheimlicher

Description

@simonheimlicher

Description

Since Hugo v0.153.0, the per-image quality and hint parameters are ignored when encoding WebP images. The WASM-based WebP encoder always uses the global site configuration values instead of the per-image settings.

For example, $img.Resize "300x webp q10" produces the same output as $img.Resize "300x webp q90".

Reproduction

Minimal reproduction repository: https://github.com/simonheimlicher/hugo-webp-quality-bug

git clone https://github.com/simonheimlicher/hugo-webp-quality-bug
cd hugo-webp-quality-bug
hugo
ls -la public/images/*.webp

Actual behavior (v0.153.x)

All WebP files are identical (~49KB) regardless of requested quality:

-rw-r--r-- 49432 test_hu_..._q1.webp
-rw-r--r-- 49432 test_hu_..._q10.webp
-rw-r--r-- 49432 test_hu_..._q25.webp
-rw-r--r-- 49432 test_hu_..._q50.webp
-rw-r--r-- 49432 test_hu_..._q75.webp

Expected behavior

File sizes should vary with quality (verified with standalone cwebp):

  • q1: ~6 KB
  • q75: ~49 KB

Root cause

The WASM WebP encoder is initialized once with global config values. The codec.go EncodeTo method receives the correct per-image ImageConfig but doesn't pass quality/hint to the encoder.

Affected versions

  • v0.153.0 through v0.153.4 (current)

Fix

PR #14315 addresses this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions