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

Error fps in generated gif file of write_gif_with_image_io #2170

Open
Beanpow opened this issue May 7, 2024 · 0 comments · May be fixed by #2171
Open

Error fps in generated gif file of write_gif_with_image_io #2170

Beanpow opened this issue May 7, 2024 · 0 comments · May be fixed by #2171

Comments

@Beanpow
Copy link

Beanpow commented May 7, 2024

Problem

The fps of the generated gif file of function write_gif_with_image_io is not correct.

Minimal Case

The following code is similar to the function write_gif_with_image_io, but the generated gif's fps is not equal to the fps in the code.

def write_gif_with_image_io(

import imageio
import numpy as np


filename = 'test.gif'
fps = 30
quantizer = 0
colors = 256
loop = 0

writer = imageio.save(
    filename,
    duration=1.0/fps,
    quantizer=quantizer,
    palettesize=colors,
    loop=loop
)

for i in range(100):
    writer.append_data(np.random.randint(0, 255, (3, 100, 100), dtype=np.uint8))

Potential Reason

As the following imageio code, the duration is in ms. But the write_gif_with_image_io maybe think it is second.
https://github.com/imageio/imageio/blob/ac863934d590ffc64155475a0fc365c1c82a8267/imageio/plugins/pillow.py#L408-L413

        if "fps" in kwargs:
            warnings.warn(
                "The keyword `fps` is no longer supported. Use `duration`"
                "(in ms) instead, e.g. `fps=50` == `duration=20` (1000 * 1/50).",
                DeprecationWarning,
            )
            kwargs["duration"] = 1000 * 1 / kwargs.get("fps")

writer = imageio.save(
filename, duration=1.0 / fps, quantizer=quantizer, palettesize=colors, loop=loop
)

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

Successfully merging a pull request may close this issue.

1 participant