Skip to content

Add proof of concept for planar multiband images - #10195

Draft
aclark4life wants to merge 1 commit into
mainfrom
planar-poc
Draft

aclark4life wants to merge 1 commit into
mainfrom
planar-poc

Conversation

@aclark4life

Copy link
Copy Markdown
Member

Refs #10189, #1888.

Changes proposed in this pull request:

  • Adds a private, experimental PIL._planar module as a proof of concept for the planar storage design proposed in Add design proposal for multiband and high bit depth images #10189. It may change or be removed without deprecation, and nothing public changes.
  • PlanarImage stores each band as an existing single-band core image (L, I;16, I, F), with per-band metadata (name, sample type, role: color/alpha/extra), a colorspace and a premultiplied flag. mode is a single generic value, "planar".
  • crop, transpose, resize, rotate and filter are applied per plane. With straight alpha, resize and rotate premultiply color bands first.
  • Existing modes (L, LA, La, RGB, RGBA, RGBa, CMYK, I;16, I, F, ...) convert to and from planar images losslessly.

The aim is to test the open questions in #10189 with code before proposing answers.

Findings

  1. Per-plane operations work for geometry. For RGB and fully opaque RGBA, crop, transpose, resize, rotate and blur give pixel-identical results to the interleaved image.
  2. Single-band modes have gaps. I;16 has no reduce() and no Gaussian, box, median or unsharp filters; F has no BLUR. "No new C code per operation" holds only once these are filled in.
  3. F to I;16 conversion clips at 255. Worked around here by converting through I.
  4. Premultiplied alpha works at 16 bits. A white edge against transparent black stays white when resized; resizing planes naively darkens it.
  5. 8-bit RGBa loses precision at low alpha. Compared with premultiplying in floating point, Pillow's RGBA resize differs by up to 27 levels where alpha is low, and 3–9 where alpha ≥ 128. This supports recording premultiplication as metadata rather than converting around each operation.

Not covered yet

  • Opening real high bit depth files (unpacking interleaved data into planes)
  • Arrow export of a planar image
  • Conversion between sample types
  • Integration with Image

🤖 Generated with Claude Code

Private, experimental module for the design proposal in #10189. Stores
each band as a single-band core image with per-band metadata, applies
band-independent operations per plane, and premultiplies straight alpha
when resampling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aclark4life aclark4life added the 🤖-assisted AI-assisted label Oct 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-assisted AI-assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant