Repository navigation
Accept 16-bit PNG input by stripping samples to 8 bits - #316
Open
malventano wants to merge 1 commit into
Open
malventano wants to merge 1 commit into
malventano wants to merge 1 commit into
Conversation
Image admission rejects every 16-bit PNG with HTTP 400 "PNG requires
non-animated, at most 8-bit samples". 16-bit samples occur in HDR
screenshots and in exports from image editors, with iPhone HDR
screenshots as one source. An OpenAI-compatible client that attaches
such a file loses the whole reply. Pillow-backed serving accepts these
files by retaining the high byte of each 16-bit sample.
decode_png now requests EXPAND and STRIP_16 and rejects only animated
PNG. The png crate strip transform keeps the high byte, so the existing
RGB8 loop and RgbImage need no depth branch. The decode test checks
16-bit RGB, RGBA, and grayscale output against known high-byte values
and still checks truncated input rejection. helios/README.md records the
conversion and the remaining animated PNG rejection.
16-bit PNG input now decodes to the same RGB8 bytes Pillow produces, so
these files are admitted instead of failing the request.
Validation: cargo test --features images png_drops_alpha passed. A
1320x2868 16-bit iPhone HDR screenshot decoded by the patched code was
byte identical to Pillow 13.0.0 Image.open(...).convert("RGB") for the
same file. The same file returned 200 from a local build serving
DeepSeek V4.1 Flash, both directly and through Open WebUI 0.13.3.
Animated PNG remains rejected and was not exercised beyond the existing
decode error path.
Signed-off-by: Allyn Malventano <malventano@users.noreply.github.com>
Design-Signed-Off-By: Allyn Malventano; design-review=ed22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: Image admission rejects every 16-bit PNG with HTTP 400 "PNG requires
non-animated, at most 8-bit samples". 16-bit samples occur in HDR screenshots
and in exports from image editors, with iPhone HDR screenshots as one source.
A client that attaches such a file loses the whole reply. Pillow-backed
serving accepts these files by retaining the high byte of each sample.
What changed: decode_png requests EXPAND and STRIP_16 and rejects only
animated PNG. The png strip transform keeps the high byte, so the existing
RGB8 loop and RgbImage need no depth branch. The decode test checks 16-bit
RGB, RGBA, and grayscale output against known high-byte values and still
checks truncated input rejection. helios/README.md records the conversion
and the remaining animated PNG rejection.
Benefit: 16-bit PNG input decodes to the same RGB8 bytes Pillow produces, so
these files are admitted instead of failing the request.
Evidence: cargo test --features images png_drops_alpha passed. A 1320x2868
16-bit iPhone HDR screenshot decoded by the patched code was byte identical
to Pillow 13.0.0 Image.open(...).convert("RGB"). The same file returned 200
from a local build of Flare v0.1.0 (0572fd1) with this patch, serving
DeepSeek V4.1 Flash, both directly and through Open WebUI 0.13.3. Animated
PNG remains rejected and was not exercised beyond the existing decode error
path.
Prepared by DSV4.1-Flash-1017 running on Flare v0.1.0 (0572fd1) with this
patch applied.