mirror of
https://github.com/zen-browser/theme-store.git
synced 2025-07-07 17:05:31 +02:00
Add Pillow dependency and implement image validation for theme submission
This commit is contained in:
parent
7b4c3e1628
commit
8575ce6a73
2 changed files with 9 additions and 1 deletions
1
.github/workflows/create-theme.yml
vendored
1
.github/workflows/create-theme.yml
vendored
|
@ -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
|
||||||
|
|
|
@ -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():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue