trim non-animated marseys and increase width to 300px

remotes/1693045480750635534/spooky-22
Aevann1 2022-09-11 10:49:46 +02:00
parent 8127af07ca
commit 14961d856f
2 changed files with 7 additions and 4 deletions

View File

@ -88,7 +88,7 @@ def process_video(file):
def process_image(filename=None, resize=0):
def process_image(filename=None, resize=0, trim=False):
size = os.stat(filename).st_size
if size > 16 * 1024 * 1024 or not patron and size > 8 * 1024 * 1024:
@ -98,8 +98,11 @@ def process_image(filename=None, resize=0):
i = Image.open(filename)
if resize and i.width > resize:
try: subprocess.run(["convert", filename, "-coalesce", "-resize", f"{resize}>", filename])
except: pass
if trim and len(list(Iterator(i))) == 1:
subprocess.run(["convert", filename, "-coalesce", "-trim", "-resize", f"{resize}>", filename])
else:
try: subprocess.run(["convert", filename, "-coalesce", "-resize", f"{resize}>", filename])
except: pass
elif i.format.lower() != "webp":
exif = i.getexif()

View File

@ -79,7 +79,7 @@ def submit_marsey(v):
filename = f'/asset_submissions/marseys/{name}.webp'
copyfile(highquality, filename)
process_image(filename, 200)
process_image(filename, resize=300, trim=True)
marsey = Marsey(name=name, author_id=author.id, tags=tags, count=0, submitter_id=v.id)
g.db.add(marsey)