forked from MarseyWorld/MarseyWorld
trim non-animated marseys and increase width to 300px
parent
8127af07ca
commit
14961d856f
|
@ -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,6 +98,9 @@ def process_image(filename=None, resize=0):
|
|||
i = Image.open(filename)
|
||||
|
||||
if resize and i.width > resize:
|
||||
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":
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue