videos: remove video uploads lol

This commit is contained in:
justcool393 2023-02-17 19:26:40 -08:00 committed by GitHub
parent 0f10e1ea16
commit 872d9c613b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 30 additions and 136 deletions

28
files/helpers/media.py Normal file
View file

@ -0,0 +1,28 @@
import subprocess
from flask import Request
from PIL import Image, ImageOps
from webptools import gifwebp
def process_image(filename=None, resize=0):
i = Image.open(filename)
if resize and i.width > resize:
try: subprocess.call(["convert", filename, "-coalesce", "-resize", f"{resize}>", filename])
except: pass
elif i.format.lower() != "webp":
exif = i.getexif()
for k in exif.keys():
if k != 0x0112:
exif[k] = None
del exif[k]
i.info["exif"] = exif.tobytes()
if i.format.lower() == "gif":
gifwebp(input_image=filename, output_image=filename, option="-mixed -metadata none -f 100 -mt -m 6")
else:
i = ImageOps.exif_transpose(i)
i.save(filename, format="WEBP", method=6)
return filename