From c64f0595394bc45288d07ba2e4b7d6b03f417659 Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 21 May 2024 01:48:21 +0300 Subject: [PATCH] check if above 2MB and give user error --- files/routes/art_submissions.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/files/routes/art_submissions.py b/files/routes/art_submissions.py index c8641ba0d..81057e701 100644 --- a/files/routes/art_submissions.py +++ b/files/routes/art_submissions.py @@ -71,6 +71,16 @@ def submit_art_post(v): file.save(highquality) process_image(highquality, v) #to ensure not malware + # #to ensure under 2MB + temp = f'/asset_submissions/art/{entry.id}-t.webp' + copyfile(highquality, temp) + trim = (entry.kind == 'sidebar') + try: process_image(temp, v, resize=entry.resize, trim=trim) + except: + os.remove(highquality) + abort(413, f"Max size for site assets is {MAX_IMAGE_SIZE_BANNER_RESIZED_MB} MB") + os.remove(temp) + if kind == "banner" and v.id != AEVANN_ID: with Image.open(highquality) as i: if i.width != 2000 or i.height != 200: