# Fix imageio GIFs That Play With No Frame Delay After Upgrading (mimsave duration)

Yes. An agent finds the imageio 2.28 change that reads duration in milliseconds, fixes your GIF writer, pins the release and adds a test that checks the frame delay.

[Run this on Rush](https://cloud.getrush.ai/run/fix-imageio-mimsave-gif-duration-ignored/imageio/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

imageio 2.28.0 changed what `duration` means to the Pillow GIF writer. On 2.27.0, `imageio.mimsave(path, frames, 'GIF', duration=0.1)` writes a GIF whose frames last 100 ms each; on 2.28.0 and on today's 2.38.1 the same call writes frames with no delay at all, because the value is now read as milliseconds and 0.1 ms rounds to nothing. No warning is printed and no exception is raised; the file is written, has the right number of frames, and plays as a flicker. The same release line also deprecates the top-level reader: `imageio.imread` on 2.38.1 prints `DeprecationWarning: Starting with ImageIO v3 the behavior of this function will switch to that of iio.v3.imread`, pointing at `imageio.v2` to keep the old behavior.

In an augmentation tool like RubanSeven/Text-Image-Augmentation-python, `demo.py` defines `create_gif(image_list, gif_name, duration=0.1)` and writes with `imageio.mimsave(gif_name, frames, 'GIF', duration=duration)` on line 13. Its main block reads `imgs/demo.png` with OpenCV, resizes it to 200 by 64, builds twelve distorted, stretched and perspective-warped frames with the functions in `augment.py`, showing each with `cv2.imshow` and `cv2.waitKey(100)`, and then writes `imgs/distort.gif`, `imgs/stretch.gif` and `imgs/perspective.gif`. The three GIFs committed in `imgs/` have twelve frames of 100 ms each, which is what the code produced when it was written. There is no requirements file; the README names Python 3.6.4 and NumPy 1.14.0, and imageio and OpenCV are imported without being listed.

The agent reproduces it headless, since the sandbox has no display for `cv2.imshow`: it installs `opencv-python-headless`, imageio and NumPy, imports `create_gif` and `distort` without running the demo's main block, builds four distorted frames from `imgs/demo.png`, and calls `create_gif` with the default duration. Reading the result back with Pillow shows four frames and no delay. The same call with `duration=100` gives 100 ms, and installing imageio 2.27.0 beside the current Pillow gives 100 ms from `duration=0.1`, so the boundary is the imageio release and not Pillow or the frames. It greps the repository for `imread`, `imwrite`, `mimsave` and `get_reader` so the pull request lists every imageio call, not only the one that broke.

The fix the agent proposes is to write through the v3 API, which takes an explicit unit: `imageio.v3.imwrite(path, numpy.stack(frames), duration=100, loop=0)` produces frames of 100 ms that loop, checked the same way. `create_gif` keeps its signature but documents the value as milliseconds, and the demo's callers pass 100. A new `requirements.txt` pins `imageio>=2.28` with NumPy and OpenCV, so an install cannot land on either side of the boundary unannounced, and a test builds three synthetic frames, writes a GIF, and asserts with Pillow that it has three frames at 100 ms and a loop count of 0. The committed GIFs are left as they are, since they already play at the intended speed.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "GIFs written by this project play with no frame delay after imageio was upgraded; the writer passes duration in seconds to imageio.mimsave. In a clean virtual environment, install imageio, numpy and opencv-python-headless, report the resolved versions, and reproduce it without a display: import the GIF-writing function and the frame-generating functions without running the demo's main block, build a few frames from the sample image, write a GIF with the default duration and read its frame count and per-frame delay back with Pillow. Repeat with the same value passed as milliseconds, and once more on imageio 2.27.0, so the pull request shows which release changed the unit. List every imageio call in the repository with file and line. Change the writer to imageio.v3.imwrite with duration in milliseconds and loop=0, keeping the function's signature, and update its callers. Add a requirements.txt that pins imageio to 2.28 or newer. Add a test that writes a GIF from synthetic frames and asserts the frame count, the delay and the loop count with Pillow. Run the test and open a pull request with the three readback results and the list of calls.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

A pull request that changes the GIF-writing function and its callers, adds `requirements.txt` and a test file. The description opens with a small table of the three readbacks: the default call on the current imageio with no delay, the same call with milliseconds, and the old release with seconds, each with the frame count Pillow reported. Below it is every imageio call in the repository with file and line, and whether it changed.

The session's record keeps the installs with their resolved versions, each write-and-readback command and the test run. A reviewer who wants to see a frame opens the GIF the test wrote from the session's artifacts rather than trusting the numbers.

Before merging, a reviewer checks that every caller now passes milliseconds, that the pinned lower bound matches what colleagues install, and whether the committed example GIFs should be regenerated from the new writer so the README's animations and the code agree.

## Run it on every Dependabot pull request for imageio

This change arrived without an error, so a test that reads the delay back is the only thing that catches the next one. A bot sender never fires an automation's `github` trigger, so give the automation a `webhook` trigger and add a workflow step on the bump that runs when its title names imageio or Pillow and posts the pull request number to the trigger's URL with `Authorization: Bearer` and the trigger's secret; the event lands after the prompt, and the run writes a GIF against the bumped release, reads it back and reports whether the delay held.

From your own server the same request goes to `POST /o/{org}/sessions` with the repository in `resources`. Give it a `request_id` that is a UUID v5 of the pull request number, so a retried delivery returns the run that already started instead of opening a second pull request.

## Why run it on Rush?

There is no traceback to paste. Finding this means writing GIFs on two imageio releases and reading each one back with another library, from code that opens windows on a laptop and cannot run in CI as written. In a Rush sandbox the agent imports the functions it needs, generates the frames and keeps every GIF it wrote as an artifact, and the machine is gone when the run ends.

What comes back is a measurement, not an opinion: frame counts and delays per release in the transcript, and a test that repeats the measurement on every run. A team with several image pipelines on the same helper starts one run per repository with the same request, up to the key's `max_concurrent` limit at once, and the rest queue.

## Frequently asked questions

### Why is there no error if the unit changed?

Because the value is still a valid duration. imageio 2.28 and later pass it to Pillow as milliseconds, and 0.1 ms rounds to no delay, so the writer succeeds and the file plays as a flicker. The only way to see it is to read the frame delay back, which is what the agent's test does.

### Is passing duration=100 to mimsave enough?

On the current release, yes: the agent's readback shows 100 ms. But `mimsave` is the v2 API, and the top-level functions already warn that their behavior switches with v3. Writing through `imageio.v3.imwrite` names the unit and the loop count explicitly, which is why the pull request moves to it instead of only changing the number.

### Can the agent run the demo if it opens windows?

It does not run the demo's main block. The sandbox has no display, so `cv2.imshow` would fail; the agent imports the frame functions and the writer directly, builds frames from the sample image with `opencv-python-headless`, and tests the writer on its own. The demo script keeps its windows for people who run it locally.

### Should the committed GIFs be regenerated?

They already have 100 ms frames, so they play correctly; the pull request leaves them alone and says so. Regenerating them from the fixed writer is listed as an optional follow-up for whoever maintains the README's animations.

## More jobs like this: Fix a bug from an alert

- [Fix "SyntaxError: Unexpected identifier 'assert'" in rollup.config.js on Node.js 22](https://getrush.ai/run/fix-import-assertions-syntax-error/rollup/)
- [Fix "error TS5102: Option 'importsNotUsedAsValues' has been removed" in tsconfig.json](https://getrush.ai/run/fix-importsnotusedasvalues-removed/typescript/)
- [Fix "ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape"](https://getrush.ai/run/fix-inhomogeneous-shape-value-error/numpy/)
- [Fix "AttributeError: module 'inspect' has no attribute 'getargspec'" on Python 3.11](https://getrush.ai/run/fix-inspect-getargspec-attribute-error/inspect/)
- [Fix TypeError: Cannot Read Properties of Undefined (Reading 'FLAGS') in discord.js 14](https://getrush.ai/run/fix-intents-flags-removed/discord-js/)
- [Fix "NotImplementedError: interp2d has been removed in SciPy 1.14.0"](https://getrush.ai/run/fix-interp2d-has-been-removed/scipy/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
