Add Pillow dependency and implement image validation for theme submission

This commit is contained in:
mr. m 2025-02-19 11:26:07 +00:00
parent 7b4c3e1628
commit 8575ce6a73
2 changed files with 9 additions and 1 deletions

View file

@ -21,6 +21,7 @@ jobs:
- name: Setup python modules - name: Setup python modules
run: | run: |
pip3 install requests pip3 install requests
pip3 install pillow
- name: Parse issue - name: Parse issue
id: issue-parser id: issue-parser

View file

@ -8,7 +8,7 @@ import sys
import requests import requests
import urllib.parse import urllib.parse
from enum import StrEnum from enum import StrEnum
from PIL import Image
class PreferenceFields(StrEnum): class PreferenceFields(StrEnum):
PROPERTY = "property" PROPERTY = "property"
@ -305,6 +305,13 @@ def download_image(image_url, image_path):
panic("Image must be a PNG.") panic("Image must be a PNG.")
with open(image_path, "wb") as f: with open(image_path, "wb") as f:
f.write(response.content) 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(): def main():