Skip to content
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

artists.stitch_to_animation: gif generation can have low color fidelity #1182

Open
ddkohler opened this issue May 29, 2024 · 1 comment
Open

Comments

@ddkohler
Copy link
Contributor

e.g. the component images of a 2D pcolormesh might have a smooth color gradient:

original

but the gif reduces the color size to be very segmented:

segmented

GIFs can only use a 256 color palette, but this is clearly more segmented than that. Maxing the palette_size kwarg to 256 does not fix this issue.

Proposing to add settings that allows for more color fidelity.

@ddkohler
Copy link
Contributor Author

When pillow writes a gif from our images (pngs), it needs to define a palette to use. The images are imported in RGBA format (so they pixels are given a transparency value), and it appears that devoting colors to allow transparency significantly uses up the palette. If I convert the images to RGB before inserting them into the gif, the palette is built with much higher resolution.

So my current solution removes transparency, which might be desired in some cases. Still, it's progress, and the fix is simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant