-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
"Noise" in the background of GIF animations #4263
Comments
By changing the mode of the image to P, I find that the following code works - from PIL import Image, ImageDraw, ImageFont
from io import BytesIO
save_kwargs = {
"format": "GIF",
"save_all": True,
"duration": 100,
"loop": False,
}
font = ImageFont.truetype(font="/System/Library/Fonts/Supplemental/Arial.ttf", size=36)
frames = []
for i in range(0, 20):
frame = Image.new("P", (200, 200), color="#FFAD94")
draw = ImageDraw.Draw(frame)
draw.text((90, 90), str(i), "#fff", font=font)
frames.append(frame)
frames[0].save("bad.gif", append_images=frames[1:], **save_kwargs) |
Thanks @radarhere , changing "RGB" to "P" works perfectly - and was about 10x faster than "RGB" mode! |
Does that resolve this issue for you then? |
Yes, thank you! |
If we are not creating the image by |
To change an image from one mode to another, use the |
What did you do?
Saved an animated GIF with a plain background and an incrementing integer in the middle.
What did you expect to happen?
The output should look like this (the "good" gif):
What actually happened?
The output looks like this (the "bad" gif):
Notice the background is full of noise, and the noise at the bottom right changes every frame.
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: