Skip to content

Floor Pillow at 10.2 so the bundled libjpeg-turbo cannot corrupt thumbnails - #24

Merged
abrignoni merged 1 commit into
mainfrom
fix/pillow-jpeg-encoder-floor
Sep 3, 2026
Merged

abrignoni merged 1 commit into
mainfrom
fix/pillow-jpeg-encoder-floor

Conversation

@abrignoni

Copy link
Copy Markdown
Owner

Floors Pillow at 10.2 in requirements.txt and pyproject.toml.

  • The macOS arm64 wheels of Pillow 10.0.1 and 10.1.0 bundle libjpeg-turbo 3.0.0 built without SIMD. Its Huffman encoder branches on a flag it never set, so about every other JPEG of a small image came out with the wrong leading bits. Pillow 10.2.0 is the first wheel with the fixed 3.0.1.
  • Adds a test that encodes a white tile forty times through the thumbnail path and requires one byte stream that decodes white.
  • Restores the pixel comparison in the archive-reference test and corrects its comment.
  • Records the measurement in the cross-platform rules.

🤖 Generated with Claude Code

…bnails

Pillow 10.0.1 and 10.1.0 wheels for macOS arm64 bundle libjpeg-turbo 3.0.0 built
without SIMD. That release allocates its Huffman encoder state without zeroing it,
sets the simd flag only when SIMD is compiled in, and still branches on the flag in
flush_bits, so on AArch64 a stale nonzero byte flushes the bit buffer with the wrong
count. Measured: a white 4x4, 16x16, 48x36 or 48x48 tile encodes to one of two byte
streams, about a coin flip per call, one correct and one with the leading bits wrong,
in RGB and L mode and at 4:4:4 and 4:2:0. Headers identical, only the scan differs.
Pillow 10.2.0 is the first wheel with libjpeg-turbo 3.0.1, where the branch is
compiled out; 10.2.0 through 12.3.0 give the correct stream 20 of 20 times.

Adds a test that encodes a white tile forty times through make_image_thumb and
requires one byte stream that decodes white, which fails deterministically on an
affected build and passes on 10.2 and later. Corrects the comment in the
archive-reference test that blamed the partial macroblock and restores the pixel
comparison there. Records the measurement in the cross-platform rules.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@abrignoni
abrignoni merged commit 8d504c0 into main Sep 3, 2026
11 checks passed
@abrignoni
abrignoni deleted the fix/pillow-jpeg-encoder-floor branch September 3, 2026 19:52
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