From 0ec3e61118614bcda1638c3440485662602bf25b Mon Sep 17 00:00:00 2001 From: retoor Date: Fri, 31 Jul 2026 22:50:54 +0200 Subject: [PATCH] Move image pixel reads to get_flattened_data and add the font libraries 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) --- Dockerfile | 2 ++ devplacepy/awards/images.py | 2 +- devplacepy/services/jobs/isslop/analysis/domsignals/color.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5c05dd6c..7d1fcd03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ WORKDIR /app RUN apt-get update && apt-get install -y --no-install-recommends \ 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/* # Optional: the docker CLI so the (admin-only) container manager can drive the host diff --git a/devplacepy/awards/images.py b/devplacepy/awards/images.py index bce5069f..59bd29a2 100644 --- a/devplacepy/awards/images.py +++ b/devplacepy/awards/images.py @@ -12,7 +12,7 @@ def enforce_rgba_png(file_bytes: bytes) -> bytes: corner = img.getpixel((0, 0)) if len(corner) == 4 and corner[3] == 255: bg = corner[:3] - data = img.getdata() + data = img.get_flattened_data() cleaned = [] for pixel in data: if pixel[:3] == bg: diff --git a/devplacepy/services/jobs/isslop/analysis/domsignals/color.py b/devplacepy/services/jobs/isslop/analysis/domsignals/color.py index 3b52fd4a..105f780e 100644 --- a/devplacepy/services/jobs/isslop/analysis/domsignals/color.py +++ b/devplacepy/services/jobs/isslop/analysis/domsignals/color.py @@ -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.resize((64, 64)) 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) if saturation < 0.15 or lightness < 0.05 or lightness > 0.95: continue