re\
This commit is contained in:
parent
884fe9d36b
commit
2017d8ab99
1 changed files with 2 additions and 7 deletions
|
@ -67,19 +67,14 @@ def upload_imgur(filepath=None, file=None, resize=False):
|
||||||
else: format = filepath.split('.')[-1].lower().replace('jpg','png').replace('jpeg','png')
|
else: format = filepath.split('.')[-1].lower().replace('jpg','png').replace('jpeg','png')
|
||||||
|
|
||||||
if resize:
|
if resize:
|
||||||
# if format = "gif":
|
|
||||||
# new_image = Image.new("RGBA", image.size, "WHITE") # Create a white rgba background
|
|
||||||
# new_image.paste(image, (0, 0), image) # Paste the image on the background. Go to the links given below for details.
|
|
||||||
# new_image.convert('RGB').save('test.jpg', "JPEG") # Save as JPEG
|
|
||||||
|
|
||||||
i = IImage.open(filepath)
|
|
||||||
size = 100, 100
|
size = 100, 100
|
||||||
frames = ImageSequence.Iterator(i)
|
frames = ImageSequence.Iterator(i)
|
||||||
|
|
||||||
def thumbnails(frames):
|
def thumbnails(frames):
|
||||||
for frame in frames:
|
for frame in frames:
|
||||||
thumbnail = frame.copy()
|
thumbnail = frame.copy()
|
||||||
thumbnail.thumbnail(size, IImage.ANTIALIAS)
|
if format == "gif": thumbnail.thumbnail(size, IImage.ANTIALIAS).convert('RGB')
|
||||||
|
else: thumbnail.thumbnail(size, IImage.ANTIALIAS)
|
||||||
yield thumbnail
|
yield thumbnail
|
||||||
|
|
||||||
frames = thumbnails(frames)
|
frames = thumbnails(frames)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue