From c0a209226debd5cec9a252862073f904c889145b Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sun, 8 Feb 2026 12:20:31 -0800 Subject: [PATCH] fix: handle RIFF padding for odd-sized WEBP chunks (#8527) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Fix WEBP workflow loading failures for files with odd-sized chunks before the EXIF chunk. ## Problem WEBP files use the RIFF container format which [requires odd-sized chunks to be padded with a single byte](https://developers.google.com/speed/webp/docs/riff_container#riff_file_format): > If Chunk Size is odd, a single padding byte -- which MUST be 0 to conform with RIFF -- is added. The `getWebpMetadata` function was not accounting for this padding, causing it to miss the EXIF chunk in files with odd-sized preceding chunks. This resulted in "Unable to find workflow in [filename].webp" errors for valid WEBP files. ## Solution Add the padding byte to the offset calculation: ```typescript offset += 8 + chunk_length + (chunk_length % 2) ``` ## Testing - Tested with the sample image provided in the issue which previously failed to load Fixes #8076 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8527-fix-handle-RIFF-padding-for-odd-sized-WEBP-chunks-2fa6d73d3650815fb849fb6a4e767162) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action --- src/scripts/pnginfo.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scripts/pnginfo.ts b/src/scripts/pnginfo.ts index 58fe2da0f..d0b6ee3e4 100644 --- a/src/scripts/pnginfo.ts +++ b/src/scripts/pnginfo.ts @@ -124,7 +124,9 @@ export function getWebpMetadata(file: File) { break } - offset += 8 + chunk_length + // RIFF spec requires odd-sized chunks to be padded with a single byte + // https://developers.google.com/speed/webp/docs/riff_container#riff_file_format + offset += 8 + chunk_length + (chunk_length % 2) } r(txt_chunks)