Move image pixel reads to get_flattened_data and add the font libraries
Some checks failed
DevPlace CI / test (push) Failing after 1h5m59s
Some checks failed
DevPlace CI / test (push) Failing after 1h5m59s
Pillow 12 renames Image.getdata to get_flattened_data; the award image normaliser and the isslop hue histogram both read pixels that way. The image stack also needs pango, harfbuzz, fontconfig and a base font in the container, so text rendering has glyphs to work with. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a78b656ef9
commit
0ec3e61118
@ -4,6 +4,8 @@ WORKDIR /app
|
|||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
curl ca-certificates \
|
curl ca-certificates \
|
||||||
|
libglib2.0-0 libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b libfontconfig1 \
|
||||||
|
fonts-dejavu-core \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Optional: the docker CLI so the (admin-only) container manager can drive the host
|
# Optional: the docker CLI so the (admin-only) container manager can drive the host
|
||||||
|
|||||||
@ -12,7 +12,7 @@ def enforce_rgba_png(file_bytes: bytes) -> bytes:
|
|||||||
corner = img.getpixel((0, 0))
|
corner = img.getpixel((0, 0))
|
||||||
if len(corner) == 4 and corner[3] == 255:
|
if len(corner) == 4 and corner[3] == 255:
|
||||||
bg = corner[:3]
|
bg = corner[:3]
|
||||||
data = img.getdata()
|
data = img.get_flattened_data()
|
||||||
cleaned = []
|
cleaned = []
|
||||||
for pixel in data:
|
for pixel in data:
|
||||||
if pixel[:3] == bg:
|
if pixel[:3] == bg:
|
||||||
|
|||||||
@ -188,7 +188,7 @@ def _screenshot_hue_buckets(screenshot_bytes: bytes) -> dict[int, int]:
|
|||||||
image = Image.open(io.BytesIO(screenshot_bytes)).convert("RGB")
|
image = Image.open(io.BytesIO(screenshot_bytes)).convert("RGB")
|
||||||
image = image.resize((64, 64))
|
image = image.resize((64, 64))
|
||||||
buckets: dict[int, int] = {}
|
buckets: dict[int, int] = {}
|
||||||
for r, g, b in image.getdata():
|
for r, g, b in image.get_flattened_data():
|
||||||
hue, lightness, saturation = colorsys.rgb_to_hls(r / 255.0, g / 255.0, b / 255.0)
|
hue, lightness, saturation = colorsys.rgb_to_hls(r / 255.0, g / 255.0, b / 255.0)
|
||||||
if saturation < 0.15 or lightness < 0.05 or lightness > 0.95:
|
if saturation < 0.15 or lightness < 0.05 or lightness > 0.95:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user