question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Passing `duration` or `fps` has no effect on the output GIF using PillowPlugin

See original GitHub issue
import imageio.v3 as iio
import matplotlib.pyplot as plt

gif_path = "test.gif"
frames_path = "{i}.jpg"

n = 20
plt.figure(figsize=(4,4))
for x in range(n):
    plt.scatter(x/n, x/n)
    plt.xlim(0, 1)
    plt.ylim(0, 1)
    plt.savefig(f"{x}.jpg")

frames = np.stack(
    [iio.imread(f"{i}.jpg") for i in range(n)],
    axis=0
)

iio.imwrite(gif_path, frames, fps=1, loop=0)

I’ve tried duration=1000 too

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
FirefoxMetzgercommented, Aug 29, 2022

Of course I can. It would live in PillowPlugin.write.

The way it works under the hood is that imopen selects the plugin, instantiates it, and returns it (a typical factory). imwrite calls imopen internally to figure out the plugin to use and then calls plugin.write to do the actual writing.

1reaction
FirefoxMetzgercommented, Aug 29, 2022

No, I think you got that one right. The old pillow plugin added fps on top of pillow’s native duration. I didn’t port that addition into the new PillowPlugin because it is redundant. It is also more limiting because duration allows an iterable with one duration per frame whereas something like fps=[1, 1/50, 1/25, 1/25] seems a bit odd.

That said, I see how fps seems like the more intuitive keyword compared to duration so we could reintroduce it as a thin wrapper around (and coexistant with) duration. (Subject to resolving the above odd edge case) What do you think?

Read more comments on GitHub >

github_iconTop Results From Across the Web

imageio.plugins.pillow_legacy — imageio 2.22.4 documentation
(Only available in GIF-PIL) The number of frames per second. If duration is not given, the duration for each frame is set to...
Read more >
imageio/pillow_legacy.py at master - GitHub
(Only available in GIF-PIL). The number of frames per second. If duration is not given, the. duration for each frame is set to...
Read more >
Get frames per second of a gif in python? - Stack Overflow
In GIF files, each frame has its own duration. So there is no general fps for a GIF file. The way PIL supports...
Read more >
imageio Documentation - Read the Docs
When creating a GIF using imageio the resulting images can get quite heavy, as the created GIF is not optimized. This can be...
Read more >
How to create animated GIF with Pillow in Python - nkmk note
This article describes how to create an animated GIF with Pillow in Python.How to make GIF from images with Image.save() Sample code to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found