Skip to content

fix(build): ship libwebpdemux2 so pi3 Pillow can save WebP - #3042

Merged
vpetersson merged 1 commit into
masterfrom
fix/pi3-pillow-webp-runtime-lib
Jun 9, 2026
Merged

fix(build): ship libwebpdemux2 so pi3 Pillow can save WebP#3042
vpetersson merged 1 commit into
masterfrom
fix/pi3-pillow-webp-runtime-lib

Conversation

@vpetersson

Copy link
Copy Markdown
Contributor

What

The upload image-normalisation pipeline converts HEIC/HEIF/TIFF/etc. to lossless WebP via Pillow. On 32-bit Pi (armv7) there's no Pillow wheel, so it's compiled from source against libwebp-dev and dynamically links the whole webp family at runtime.

The runtime image only carried libwebp7 + libwebpmux3 (both transitive deps of ffmpeg's libavcodec) — but not libwebpdemux2, which nothing else pulls. Without it, import PIL._webp can't resolve libwebpdemux.so.2, the WebP plugin registers no save handler, and the conversion dies with KeyError: 'WEBP' (Sentry ANTHIAS-1Y, 11 events, all pi3).

Fix

Add libwebp7 / libwebpdemux2 / libwebpmux3 to the runtime base_apt_dependencies explicitly so the pipeline never depends on ffmpeg's transitive graph — same rationale as the libheif1 entry beside them. Inert on 64-bit boards (their Pillow wheel bundles its own webp libs), so listed unconditionally for simplicity, matching libheif1.

Verification

On debian:trixie, a from-source Pillow==12.2.0 _webp.so links:

libwebp.so.7    libwebpmux.so.3    libwebpdemux.so.2    libsharpyuv.so.0

Installing only ffmpeg + libheif1 (runtime parity) leaves libwebpdemux2 absent while the other three are present — exactly the failure signature. Generated Dockerfile.server for pi3 now installs all three at runtime alongside libheif1.

🤖 Generated with Claude Code

The upload image-normalisation pipeline converts HEIC/HEIF/TIFF/etc. to
lossless WebP via Pillow. On 32-bit Pi (armv7) there's no Pillow wheel,
so it's compiled from source against libwebp-dev and dynamically links
the whole webp family at runtime: libwebp7, libwebpmux3 *and*
libwebpdemux2 (Pillow's _webp uses WebPAnimDecoder).

The runtime image only pulled libwebp7 + libwebpmux3 — both transitive
deps of ffmpeg's libavcodec — but NOT libwebpdemux2, which nothing else
depends on. Without it, ``import PIL._webp`` fails to resolve
libwebpdemux.so.2, the WebP plugin registers no save handler, and the
conversion dies with ``KeyError: 'WEBP'`` (Sentry ANTHIAS-1Y, 11 events,
all pi3).

Add libwebp7 / libwebpdemux2 / libwebpmux3 to the runtime
base_apt_dependencies explicitly so the pipeline never depends on
ffmpeg's transitive graph — same rationale as the libheif1 entry beside
them. Inert on 64-bit boards (their Pillow wheel bundles its own webp
libs), so listed unconditionally for simplicity, matching libheif1.

Verified: a from-source Pillow 12.2.0 _webp.so on debian:trixie links
libwebp.so.7, libwebpmux.so.3, libwebpdemux.so.2 and libsharpyuv.so.0;
installing ffmpeg+libheif1 leaves libwebpdemux2 absent.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@vpetersson
vpetersson requested a review from a team as a code owner June 9, 2026 06:40
@vpetersson
vpetersson requested a review from Copilot June 9, 2026 06:40
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes runtime WebP support for Pillow on 32-bit Raspberry Pi (armv7) by ensuring the Anthias runtime image includes the full set of required libwebp shared libraries (including libwebpdemux.so.2), preventing PIL._webp import/link failures that lead to KeyError: 'WEBP' during image normalization.

Changes:

  • Add explicit runtime APT deps for Pillow WebP support: libwebp7, libwebpdemux2, libwebpmux3.
  • Document why these are needed (armv7 builds Pillow from source; ffmpeg does not pull libwebpdemux2 transitively).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vpetersson
vpetersson merged commit 4e47d70 into master Jun 9, 2026
10 checks passed
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.

2 participants