forked from rDrama/rDrama
parent
1dab4f7804
commit
46225890ef
|
@ -156,7 +156,7 @@ def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[in
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if len(params) > 2:
|
if len(params) > 2:
|
||||||
params.append(filename)
|
params.extend(["-strip", "-auto-orient", filename])
|
||||||
try:
|
try:
|
||||||
subprocess.run(params, timeout=MAX_IMAGE_CONVERSION_TIMEOUT)
|
subprocess.run(params, timeout=MAX_IMAGE_CONVERSION_TIMEOUT)
|
||||||
except subprocess.TimeoutExpired:
|
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. "
|
abort(413, ("An uploaded image took too long to convert to WEBP. "
|
||||||
"Please convert it to WEBP elsewhere then upload it again."))
|
"Please convert it to WEBP elsewhere then upload it again."))
|
||||||
return None
|
return None
|
||||||
|
else:
|
||||||
|
subprocess.run(["exiv2", "rm", filename], timeout=MAX_IMAGE_CONVERSION_TIMEOUT)
|
||||||
|
|
||||||
if resize:
|
if resize:
|
||||||
if os.stat(filename).st_size > MAX_IMAGE_SIZE_BANNER_RESIZED_MB * 1024 * 1024:
|
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)
|
db.add(media)
|
||||||
|
|
||||||
subprocess.run(["exiv2", "rm", filename], timeout=MAX_IMAGE_CONVERSION_TIMEOUT)
|
|
||||||
|
|
||||||
return filename
|
return filename
|
||||||
|
|
Loading…
Reference in New Issue