diff --git a/files/helpers/images.py b/files/helpers/images.py index 82f940375..b5ac52923 100644 --- a/files/helpers/images.py +++ b/files/helpers/images.py @@ -1,34 +1,23 @@ -from PIL import Image, ImageSequence, ImageOps +from PIL import Image, ImageOps +from PIL.ImageSequence import Iterator from webptools import gifwebp +import subprocess def process_image(filename=None, resize=0): i = Image.open(filename) - exif = i.getexif() - for k in exif.keys(): - if k != 0x0112: - exif[k] = None - del exif[k] - i.info["exif"] = exif.tobytes() - if resize and i.width > resize: - size = resize, resize - frames = ImageSequence.Iterator(i) - - def thumbnails(frames): - for frame in frames: - thumbnail = frame.copy() - thumbnail.thumbnail(size) - yield thumbnail - - frames = thumbnails(frames) - - om = next(frames) - om.info = i.info - om = ImageOps.exif_transpose(om) - om.save(filename, format="WEBP", save_all=True, append_images=list(frames), loop=0, method=6, allow_mixed=True) + subprocess.call(["convert", filename, "-coalesce", "-resize", f"{resize}>", filename]) 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: diff --git a/files/routes/posts.py b/files/routes/posts.py index 2be4be84e..b9ad0ac35 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -126,7 +126,9 @@ def submit_get(v, sub=None): if request.path.startswith('/s/') and not sub: abort(404) - return render_template("submit.html", SUBS=tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, sub=sub, ghost=submit_ghost(v,g.db)) + SUBS = () if SITE_NAME == 'Drama' and not sub else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()) + + return render_template("submit.html", SUBS=SUBS, v=v, sub=sub, ghost=submit_ghost(v,g.db)) @app.get("/post/") @app.get("/post//") @@ -853,10 +855,12 @@ def submit_post(v, sub=None): def error(error): if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": error}, 403 - return render_template("submit.html", SUBS=tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()), v=v, error=error, title=title, url=url, body=body, ghost=submit_ghost(v,g.db)), 400 + + SUBS = () if SITE_NAME == 'Drama' and not sub else tuple(x[0] for x in g.db.query(Sub.name).order_by(Sub.name).all()) + return render_template("submit.html", SUBS=SUBS, v=v, error=error, title=title, url=url, body=body, ghost=submit_ghost(v,g.db)), 400 - if not sub: sub = request.values.get("sub") + sub = request.values.get("sub") if sub: sub = g.db.query(Sub.name).filter_by(name=sub.strip().lower()).one_or_none() diff --git a/files/routes/settings.py b/files/routes/settings.py index d1991f4a8..7347c901e 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -345,6 +345,10 @@ def settings_profile_post(v): if house == "None": house = None v.house = house + + if v.house == "Vampire": + send_repeatable_notification(DAD_ID, f"@{v.username} has joined House Vampire!") + updated = True quadrant = request.values.get("quadrant") diff --git a/files/templates/header.html b/files/templates/header.html index ebfebc031..058d69bc1 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -65,14 +65,15 @@ {% endif %} {% if not err %} - + {% if v and v.admin_level > 1 %} - + {% endif %} + {% if v %} - + {% else %} - + {% endif %}