fd
This commit is contained in:
parent
359620464e
commit
65ad328b17
1 changed files with 14 additions and 14 deletions
|
@ -15,25 +15,25 @@ def upload_ibb(file=None, resize=False):
|
||||||
|
|
||||||
if file: file.save("image.webp")
|
if file: file.save("image.webp")
|
||||||
|
|
||||||
i = IImage.open("image.webp")
|
if resize:
|
||||||
frames = ImageSequence.Iterator(i)
|
i = IImage.open("image.webp")
|
||||||
|
size = 100, 100
|
||||||
|
frames = ImageSequence.Iterator(i)
|
||||||
|
|
||||||
def thumbnails(frames):
|
def thumbnails(frames):
|
||||||
for frame in frames:
|
for frame in frames:
|
||||||
if resize:
|
|
||||||
thumbnail = frame.copy()
|
thumbnail = frame.copy()
|
||||||
thumbnail.thumbnail(100, 100, IImage.ANTIALIAS)
|
thumbnail.thumbnail(size, IImage.ANTIALIAS)
|
||||||
yield thumbnail
|
yield thumbnail
|
||||||
else: yield frame
|
|
||||||
|
|
||||||
frames = thumbnails(frames)
|
frames = thumbnails(frames)
|
||||||
|
|
||||||
om = next(frames)
|
om = next(frames)
|
||||||
om.info = i.info
|
om.info = i.info
|
||||||
try: om.save("image.webp", save_all=True, append_images=list(frames), loop=0, optimize=True, quality=30)
|
try: om.save("image.webp", save_all=True, append_images=list(frames), loop=0, optimize=True, quality=30)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open("image.webp", 'rb') as f:
|
with open("image.webp", 'rb') as f:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue