Skip to content

Conversation

@flagman
Copy link

@flagman flagman commented Jun 2, 2025

Summary

Fixes a bug in VP8X WebP dimension parsing where reported dimensions were 1 pixel smaller than actual size in both width and height.

Problem

VP8X format stores canvas dimensions as (width-1, height-1) in the header, but the parser was returning these raw values without adding 1, causing incorrect dimensions to be reported.

Example:

  • Before: VP8X image 200×1 → returned (199, 0)
  • After: VP8X image 200×1 → returns (200, 1)

Changes

  • Add +1 to both width and height when parsing VP8X headers in imagesize.py
  • Add test case test_load_webp_vp8x() with VP8X test image (200×1)
  • Follows WebP specification for VP8X chunk format

Test plan

  • Added VP8X test case with test_vp8x.webp (200×1 image)
  • Verified fix resolves dimension parsing issue
  • All existing tests continue to pass
  • VP8L format continues to work correctly (already had correct +1)

Technical Details

The VP8X chunk format stores canvas width and height as 24-bit little-endian values representing (actual_width - 1) and (actual_height - 1) according to the WebP specification. The VP8L parser already correctly adds 1, but VP8X was missing this adjustment.

This fix ensures consistency across WebP format parsers and compliance with the WebP specification.

VP8X format stores canvas dimensions as (width-1, height-1) in the header,
but the parser was returning the raw values without adding 1, causing
incorrect dimensions to be reported.

Changes:
- Add +1 to both width and height when parsing VP8X headers
- Add test case for VP8X format with test_vp8x.webp (200x1)
- Follows WebP specification for VP8X chunk format

Fixes issue where VP8X images returned dimensions that were 1 pixel
smaller than actual size in both width and height.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant