-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
Description
I am currently using Pillow 9.4.0 and have noticed that the GifImagePlugin. py source code of Pillow uses this code to convert RGBA to P mode when processing GIFs, resulting in a loss of image quality. How can I resolve this issue?
im=im.convert("P", palette=Image. Palette. AdaPTIVE)

This is the input GIF

This is the saved GIF

Here is my code:
from PIL import Image, ImageSequence, GifImagePlugin
GifImagePlugin.LOADING_STRATEGY = GifImagePlugin.LoadingStrategy.RGB_AFTER_DIFFERENT_PALETTE_ONLY
gif = Image.open("input.gif")
frames = [frame.copy() for frame in ImageSequence.Iterator(gif)]
frames[0].save(
"output.gif",
save_all=True,
append_images=frames[1:],
optimize=False,
disposal=2,
lossless=True,
loop=0
)