forked from rDrama/rDrama
imagemagick is really cringe
parent
5d2dbee95e
commit
1a4600bd95
|
@ -143,8 +143,7 @@ def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[in
|
||||||
try:
|
try:
|
||||||
with Image.open(filename) as i:
|
with Image.open(filename) as i:
|
||||||
params = ["magick", filename]
|
params = ["magick", filename]
|
||||||
if i.format.lower() != 'webp':
|
params.extend(["-coalesce", "-quality", "88"])
|
||||||
params.extend(["-coalesce", "-quality", "88", "-define", "webp:method=5"])
|
|
||||||
if trim and len(list(Iterator(i))) == 1:
|
if trim and len(list(Iterator(i))) == 1:
|
||||||
params.append("-trim")
|
params.append("-trim")
|
||||||
if resize and i.width > resize:
|
if resize and i.width > resize:
|
||||||
|
@ -165,7 +164,7 @@ def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[in
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
if has_request:
|
if has_request:
|
||||||
abort(413, ("An uploaded image took too long to convert to WEBP. "
|
abort(413, ("An uploaded image took too long to convert to WEBP. "
|
||||||
"Consider converting it to WEBP elsewhere then uploading it."))
|
"Please convert it to WEBP elsewhere then upload it again."))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if resize:
|
if resize:
|
||||||
|
|
Loading…
Reference in New Issue