From 8575ce6a736de94ab7c22a42f0df8486e2fed024 Mon Sep 17 00:00:00 2001 From: "mr. m" <91018726+mauro-balades@users.noreply.github.com> Date: Wed, 19 Feb 2025 11:26:07 +0000 Subject: [PATCH] Add Pillow dependency and implement image validation for theme submission --- .github/workflows/create-theme.yml | 1 + scripts/submit_theme.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create-theme.yml b/.github/workflows/create-theme.yml index 312c2968..5ccd231d 100644 --- a/.github/workflows/create-theme.yml +++ b/.github/workflows/create-theme.yml @@ -21,6 +21,7 @@ jobs: - name: Setup python modules run: | pip3 install requests + pip3 install pillow - name: Parse issue id: issue-parser diff --git a/scripts/submit_theme.py b/scripts/submit_theme.py index 2b702bfe..6a1dc21e 100644 --- a/scripts/submit_theme.py +++ b/scripts/submit_theme.py @@ -8,7 +8,7 @@ import sys import requests import urllib.parse from enum import StrEnum - +from PIL import Image class PreferenceFields(StrEnum): PROPERTY = "property" @@ -305,6 +305,13 @@ def download_image(image_url, image_path): panic("Image must be a PNG.") with open(image_path, "wb") as f: f.write(response.content) + validate_image(image_path) + +def validate_image(image_path): + # Size must be 600x400 + image = Image.open(image_path) + if image.size != (600, 400): + panic("Image must be 600x400 pixels.") def main():