-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Improperly saving gif frame with some gif images #5734
Copy link
Copy link
Closed
Labels
Description
from PIL import Image, ImageSequence
def getframe(src, out):
with Image.open(src) as img:
print(f'file opened')
i = 0
for frame in ImageSequence.Iterator(img):
if i == 1:
frame.save(out)
break
else:
i += 1i used this method to get a 2nd frame of a gif image.
i got the frame but it was not good.
source gif:

result 2nd frame i got (gif format):

i tried to get 1st frame and 1st frame was very good unlike the 2nd.
i also tried another gif image has transparency.
i added convert function before save the frame
frame = frame.convert('RGB')result 2nd frame i got (jpg format):

i think the second case was occured since i did not set the background color. But there is no options about background of jpeg with Image.save().
There is some bug.. or something i missed.
Please let me know, thank you.
i used python 3.9.7 and pillow 8.3.2
Reactions are currently unavailable
