Commit 8427843
committed
images: Fix WebP quality and hint parameters being ignored
The WASM-based WebP encoder introduced in v0.153.0 ignored per-image
quality and hint parameters, always using the global site configuration.
Root cause:
- codec.go only passed quality when conf.Quality > 0, missing lossless (q0)
- No tracking for whether hint was explicitly set per-image
- webp.go EncodeOptions only handled quality override, not hint
- Validation rejected q0 (valid for lossless), and default override
defeated explicitly-set q0
Fix:
- Add hintSetForImage field to ImageConfig (mirroring qualitySetForImage)
- Pass quality/hint to encoder only when explicitly set per-image
- Handle both quality and hint overrides in webp.go EncodeOptions
- Allow q0 in validation (change "< 1" to "< 0")
- Only override with default when quality wasn't explicitly set
Test strategy:
- Golden tests validate quality by file size variance:
q0=60736B (lossless), q1=752B, q33=1688B, q75=3188B, q100=17620B
- Golden tests validate hint by distinct MD5 hashes:
photo=76ebc120..., drawing=bfaaee0d..., icon=55ecc0cd...
- Combined test (q50 drawing) validates both parameters together
AI assistance disclosure: This code was written by Antigravity with
Gemini 3 Pro (High), revised by Claude Code with Opus 4.5 (Thinking),
and reviewed by Antigravity with Gemini 3 Pro (High).1 parent b1f7e35 commit 8427843
File tree
12 files changed
+56
-10
lines changed- internal/warpc
- resources/images
- testdata/images_golden/process/webp
12 files changed
+56
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
205 | 209 | | |
206 | 210 | | |
207 | 211 | | |
| |||
299 | 303 | | |
300 | 304 | | |
301 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
302 | 320 | | |
303 | 321 | | |
304 | 322 | | |
| |||
310 | 328 | | |
311 | 329 | | |
312 | 330 | | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
| 331 | + | |
318 | 332 | | |
319 | 333 | | |
320 | 334 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
49 | 57 | | |
50 | 58 | | |
51 | 59 | | |
| |||
123 | 131 | | |
124 | 132 | | |
125 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
126 | 147 | | |
127 | 148 | | |
128 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
| |||
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
239 | | - | |
240 | | - | |
| 240 | + | |
| 241 | + | |
241 | 242 | | |
242 | 243 | | |
243 | 244 | | |
| |||
305 | 306 | | |
306 | 307 | | |
307 | 308 | | |
308 | | - | |
309 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
310 | 312 | | |
311 | 313 | | |
312 | 314 | | |
| |||
358 | 360 | | |
359 | 361 | | |
360 | 362 | | |
361 | | - | |
| 363 | + | |
| 364 | + | |
362 | 365 | | |
363 | 366 | | |
364 | 367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
391 | 399 | | |
392 | 400 | | |
393 | 401 | | |
| |||
0 commit comments