forked from MarseyWorld/MarseyWorld
dffd
parent
340119ff35
commit
7a1cad5492
|
@ -20,9 +20,13 @@ def process_image(filename=None, resize=False):
|
|||
|
||||
om = next(frames)
|
||||
om.info = i.info
|
||||
om.save(filename, save_all=True, append_images=list(frames), loop=0)
|
||||
om.save(filename, format="WEBP", save_all=True, append_images=list(frames), loop=0)
|
||||
sex = IImage.open(filename)
|
||||
print(sex.format)
|
||||
elif i.format.lower() != "webp":
|
||||
if i.format.lower() == "gif": gifwebp(input_image=filename, output_image=filename, option="-q 80")
|
||||
else: i.save(filename)
|
||||
else: i.save(filename, format="WEBP")
|
||||
sex = IImage.open(filename)
|
||||
print(sex.format)
|
||||
|
||||
return filename
|
|
@ -263,9 +263,9 @@ def api_comment(v):
|
|||
file=request.files["file"]
|
||||
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
|
||||
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.webp'
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.gif'
|
||||
file.save(name)
|
||||
url = process_image(name)
|
||||
url = request.host_url[:-1] + process_image(name)
|
||||
|
||||
body = request.values.get("body") + f"\n![]({url})"
|
||||
body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body)
|
||||
|
@ -684,9 +684,9 @@ def edit_comment(cid, v):
|
|||
file=request.files["file"]
|
||||
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
|
||||
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.webp'
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.gif'
|
||||
file.save(name)
|
||||
url = process_image(name)
|
||||
url = request.host_url[:-1] + process_image(name)
|
||||
|
||||
body += f"\n![]({url})"
|
||||
body_md = CustomRenderer().render(mistletoe.Document(body))
|
||||
|
|
|
@ -509,13 +509,13 @@ def thumbnail_thread(pid):
|
|||
db.close()
|
||||
return
|
||||
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.webp'
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.gif'
|
||||
|
||||
with open(name, "wb") as file:
|
||||
for chunk in image_req.iter_content(1024):
|
||||
file.write(chunk)
|
||||
|
||||
post.thumburl = process_image(name, True)
|
||||
post.thumburl = "https://" + site + process_image(name, True)
|
||||
db.add(post)
|
||||
db.commit()
|
||||
db.close()
|
||||
|
@ -832,9 +832,9 @@ def submit_post(v):
|
|||
), 403
|
||||
|
||||
if file.content_type.startswith('image/'):
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.webp'
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.gif'
|
||||
file.save(name)
|
||||
new_post.url = process_image(name)
|
||||
new_post.url = request.host_url[:-1] + process_image(name)
|
||||
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
|
|
|
@ -112,9 +112,9 @@ def settings_profile_post(v):
|
|||
if request.headers.get("Authorization"): return {"error": f"Image files only"}, 400
|
||||
else: return render_template("settings_profile.html", v=v, error=f"Image files only."), 400
|
||||
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.webp'
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.gif'
|
||||
file.save(name)
|
||||
url = process_image(name)
|
||||
url = request.host_url[:-1] + process_image(name)
|
||||
|
||||
bio += f"\n\n![]({url})"
|
||||
|
||||
|
@ -506,15 +506,15 @@ def settings_images_profile(v):
|
|||
|
||||
file = request.files["profile"]
|
||||
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.webp'
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.gif'
|
||||
file.save(name)
|
||||
highres = process_image(name)
|
||||
highres = request.host_url[:-1] + process_image(name)
|
||||
|
||||
if not highres: abort(400)
|
||||
|
||||
name2 = name.replace('.webp', '_resized.webp')
|
||||
name2 = name.replace('.gif', '_resized.gif')
|
||||
copyfile(name, name2)
|
||||
imageurl = process_image(name2, True)
|
||||
imageurl = request.host_url[:-1] + process_image(name2, True)
|
||||
|
||||
if not imageurl: abort(400)
|
||||
|
||||
|
@ -537,9 +537,9 @@ def settings_images_banner(v):
|
|||
|
||||
file = request.files["banner"]
|
||||
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.webp'
|
||||
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(8)}.gif'
|
||||
file.save(name)
|
||||
imageurl = process_image(name)
|
||||
imageurl = DOMAIN + process_image(name)
|
||||
|
||||
if imageurl:
|
||||
v.bannerurl = imageurl
|
||||
|
|
Loading…
Reference in New Issue