Aevann1 2022-12-21 18:47:13 +02:00
parent 1dab4f7804
commit 46225890ef
1 changed files with 3 additions and 3 deletions

View File

@ -156,7 +156,7 @@ def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[in
return None
if len(params) > 2:
params.append(filename)
params.extend(["-strip", "-auto-orient", filename])
try:
subprocess.run(params, timeout=MAX_IMAGE_CONVERSION_TIMEOUT)
except subprocess.TimeoutExpired:
@ -164,6 +164,8 @@ def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[in
abort(413, ("An uploaded image took too long to convert to WEBP. "
"Please convert it to WEBP elsewhere then upload it again."))
return None
else:
subprocess.run(["exiv2", "rm", filename], timeout=MAX_IMAGE_CONVERSION_TIMEOUT)
if resize:
if os.stat(filename).st_size > MAX_IMAGE_SIZE_BANNER_RESIZED_MB * 1024 * 1024:
@ -214,6 +216,4 @@ def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[in
)
db.add(media)
subprocess.run(["exiv2", "rm", filename], timeout=MAX_IMAGE_CONVERSION_TIMEOUT)
return filename