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

[request] more color/palette control on GIF writing #1060

Open
villares opened this issue Jan 29, 2024 · 3 comments
Open

[request] more color/palette control on GIF writing #1060

villares opened this issue Jan 29, 2024 · 3 comments

Comments

@villares
Copy link

villares commented Jan 29, 2024

Using the example code from the documentation, the number of colors seems inadequate. Is there already another way of adjusting output color reduction/quality?

from pathlib import Path
import imageio

input_dir = Path.cwd()
images = [
    imageio.v3.imread(file_path)
    for file_path in sorted(input_dir.iterdir())
    if file_path.suffix.lower() == '.png'
]
if images:
    output_path = input_dir / 'output.gif'
    imageio.v3.imwrite(
        output_path,
        images,
        duration=200,
        loop=0,
    )

Example of a PNG used as frame source (1 of 6):
010

Example output GIF result:
output

The other frames, if anyone wants to test/reproduce, are here: villares/sketch-a-day@e3772f4

@Pandede
Copy link
Contributor

Pandede commented Jan 30, 2024

PNG supports 24-bits colors while GIF only supports 8-bits colors, I think that's the reason why it is inadequate.

@villares
Copy link
Author

Cheers @Pandede, I suppose this is the root problem, but other gif-making tools provide some options on how to choose the 256 color palette, and sometimes offer dithering, for example ...

@Pandede
Copy link
Contributor

Pandede commented Jan 30, 2024

Cheers @Pandede, I suppose this is the root problem, but other gif-making tools provide some options on how to choose the 256 color palette, and sometimes offer dithering, for example ...

You may check this repository out: https://github.com/ImageOptim/gifski.

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

No branches or pull requests

2 participants