New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improperly saving gif frame with some gif images #5734
Comments
I tried to get frames of Merry Christmas file with another tools, photoscape, photoshop and they gave fine frames. So I think it might be a problem with decoding gif format in pillow. |
There is a known bug in Pillow when reading subsequent GIF frames with different palettes. For example, see #4977 for instance, which bizarrely enough, is dealing with your exact same image. |
@mrnextdoor0000 Feel free to send a PR! |
Related to #5837 ? |
#5857 will fix the first image. Here is the second frame with that PR. |
For the second image, the background color is actually coming from the image. The way that GIF stores transparency is by designating a certain color to the "transparent" one. So when you remove that transparency in order to save it as a non-transparent JPEG, it becomes visible. If you want to select a background color, here is an example where green is the background color - from PIL import Image
with Image.open("source.gif") as img:
img.seek(1)
img = img.convert("RGBA")
background = Image.new("RGB", img.size, "#0f0")
background.paste(img, (0, 0), img)
background.save("out.jpg") Let us know if that isn't satisfactory for any reason. |
i 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
source gif:
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
The text was updated successfully, but these errors were encountered: