mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-11 10:30:10 +00:00
fix: handle RIFF padding for odd-sized WEBP chunks (#8527)
## 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 <action@github.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user