dffssd
This commit is contained in:
parent
ba1784af79
commit
9f0dd972c8
5 changed files with 16 additions and 15 deletions
|
@ -4,9 +4,10 @@ import time
|
|||
|
||||
def process_image(file=None, filename=None, resize=0):
|
||||
|
||||
i = IImage.open(file)
|
||||
if not filename: filename = f'/images/{time.time()}'.replace('.','')[:-5] + '.webp'
|
||||
|
||||
i = IImage.open(file)
|
||||
|
||||
if resize:
|
||||
size = resize, resize
|
||||
frames = ImageSequence.Iterator(i)
|
||||
|
@ -24,7 +25,7 @@ def process_image(file=None, filename=None, resize=0):
|
|||
om.save(filename, format="WEBP", save_all=True, append_images=list(frames), loop=0, method=6, allow_mixed=True)
|
||||
elif i.format.lower() != "webp":
|
||||
if i.format.lower() == "gif":
|
||||
i.save(filename)
|
||||
file.save(filename)
|
||||
gifwebp(input_image=filename, output_image=filename, option="-mixed -metadata none -f 100 -mt -m 6")
|
||||
else: i.save(filename, format="WEBP", method=6)
|
||||
|
||||
|
|
|
@ -174,14 +174,14 @@ def api_comment(v):
|
|||
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
|
||||
file=request.files["file"]
|
||||
if file.content_type.startswith('image/'):
|
||||
body += f"\n\n})"
|
||||
body += f"\n\n})"
|
||||
if v.admin_level == 3:
|
||||
if parent_post.id == 37696:
|
||||
filename = 'files/assets/images/Drama/sidebar/' + str(len(listdir('files/assets/images/Drama/sidebar'))+1) + '.webp'
|
||||
text = process_image(file.stream, filename, 400)
|
||||
text = process_image(file, filename, 400)
|
||||
elif parent_post.id == 37697:
|
||||
filename = 'files/assets/images/Drama/sidebar/' + str(len(listdir('files/assets/images/Drama/banners'))+1) + '.webp'
|
||||
process_image(file.stream, filename)
|
||||
process_image(file, filename)
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
with open("video.mp4", 'rb') as f:
|
||||
|
@ -639,7 +639,7 @@ def edit_comment(cid, v):
|
|||
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
|
||||
file=request.files["file"]
|
||||
if file.content_type.startswith('image/'):
|
||||
body += f"\n\n})"
|
||||
body += f"\n\n})"
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
with open("video.mp4", 'rb') as f:
|
||||
|
|
|
@ -419,7 +419,7 @@ def edit_post(pid, v):
|
|||
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
|
||||
file=request.files["file"]
|
||||
if file.content_type.startswith('image/'):
|
||||
body += f"\n\n})"
|
||||
body += f"\n\n})"
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
with open("video.mp4", 'rb') as f:
|
||||
|
@ -848,7 +848,7 @@ def submit_post(v):
|
|||
if request.files.get("file2") and request.headers.get("cf-ipcountry") != "T1":
|
||||
file=request.files["file2"]
|
||||
if file.content_type.startswith('image/'):
|
||||
body += f"\n\n})"
|
||||
body += f"\n\n})"
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
with open("video.mp4", 'rb') as f:
|
||||
|
@ -935,8 +935,8 @@ def submit_post(v):
|
|||
file = request.files['file']
|
||||
|
||||
if file.content_type.startswith('image/'):
|
||||
new_post.url = process_image(file.stream)
|
||||
new_post.thumburl = process_image(file.stream, resize=100)
|
||||
new_post.url = process_image(file)
|
||||
new_post.thumburl = process_image(file, resize=100)
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
with open("video.mp4", 'rb') as f:
|
||||
|
|
|
@ -255,7 +255,7 @@ def settings_profile_post(v):
|
|||
if request.files.get('file'):
|
||||
file = request.files['file']
|
||||
if file.content_type.startswith('image/'):
|
||||
bio += f"\n\n})"
|
||||
bio += f"\n\n})"
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
with open("video.mp4", 'rb') as f:
|
||||
|
@ -621,11 +621,11 @@ def settings_images_profile(v):
|
|||
|
||||
file = request.files["profile"]
|
||||
|
||||
highres = process_image(file.stream)
|
||||
highres = process_image(file)
|
||||
|
||||
if not highres: abort(400)
|
||||
|
||||
imageurl = process_image(file.stream, resize=100)
|
||||
imageurl = process_image(file, resize=100)
|
||||
|
||||
if not imageurl: abort(400)
|
||||
|
||||
|
@ -652,7 +652,7 @@ def settings_images_banner(v):
|
|||
|
||||
file = request.files["banner"]
|
||||
|
||||
bannerurl = process_image(file.stream)
|
||||
bannerurl = process_image(file)
|
||||
|
||||
if bannerurl:
|
||||
if v.bannerurl and '/images/' in v.bannerurl : os.remove('/images/' + v.bannerurl.split('/images/')[1])
|
||||
|
|
|
@ -271,7 +271,7 @@ def submit_contact(v):
|
|||
if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
|
||||
file=request.files["file"]
|
||||
if file.content_type.startswith('image/'):
|
||||
body_html += f'<img data-bs-target="#expandImageModal" data-bs-toggle="modal" onclick="expandDesktopImage(this.src)" class="in-comment-image" src="{process_image(file.stream)}" loading="lazy">'
|
||||
body_html += f'<img data-bs-target="#expandImageModal" data-bs-toggle="modal" onclick="expandDesktopImage(this.src)" class="in-comment-image" src="{process_image(file)}" loading="lazy">'
|
||||
elif file.content_type.startswith('video/'):
|
||||
file.save("video.mp4")
|
||||
with open("video.mp4", 'rb') as f:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue