Skip to content

Commit a935e54

Browse files
matmenclaude
andcommitted
Fix flaky WebP alphaQuality test
It compared two encodes with the current creation time, written in seconds: two encodes a second apart (seen on Windows, Node 26) wrote different files. Both now have the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BsU2GAqbnFSNaYDBGD1Km2
1 parent 7804990 commit a935e54

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎tests/webp-lossy.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,10 @@ const alphaReferences = {
158158

159159
// alphaQuality for animations, also encoded a frame at a time
160160
const faded = new Animation([0, 1].map(i => Frame.from(new Image(40, 30).fill((x, y) => Image.rgbaToColor(200, 50 * i, 9, x * 6 + y)), 100)), 0);
161-
const fadedWebp = await faded.encodeWebP({quality: 80, alphaQuality: 0, optimize: false});
162-
const encoder = Animation.webpEncoder(40, 30, {loopCount: 0, quality: 80, alphaQuality: 0, optimize: false});
161+
// (the same creation time: it's written in seconds, two encodes can be a second apart)
162+
const metadata = {creationTime: 0};
163+
const fadedWebp = await faded.encodeWebP({quality: 80, alphaQuality: 0, optimize: false, metadata});
164+
const encoder = Animation.webpEncoder(40, 30, {loopCount: 0, quality: 80, alphaQuality: 0, optimize: false, metadata});
163165
for (const frame of faded) await encoder.add(frame);
164166
if (sha256(await encoder.finish()) !== sha256(fadedWebp)) panic('alphaQuality: the incremental encoder writes another file');
165167
for (const frame of await Animation.decode(fadedWebp)) {

0 commit comments

Comments
 (0)