imazen / imazen/imageflow

Issue with Cropping Animated Gifs

Open
#652 5 comments 0 reactions 0 assignees View on GitHub
difficult enhancement
Dominant language
Rust
Stars
4.4k
Forks
144
PR merge metrics
No merged PRs in 30d

Description

I am currently trying to evaluate ImageFlow but am running into an issue when resizing animated gifs. When resizing the following image it ends up causing it to bounce around a bit. This doesn't happen in other libraries, but seems to be happening in ImageFlow and the legacy ImageResizer.

It seems like one of the frames with the lights is causing the image to be slightly bigger than the rest of the frames. Perhaps the bug is that the image size isn't taking into account the biggest image in the sequence?

Output:

![43612_right--output-imageflow](https://github.com/user-attachments/assets/3d336caa-bbdf-4241-ac73-d7fc66f0bbaa)

```csharp
using var job = new ImageJob();

// NOTE: Removing 'trim.threshold' does fix the issue, but then it doesn't trim
await job
.Decode(await File.ReadAllBytesAsync(source))
.ResizerCommands("width=400&bgcolor=white&trim.threshold=50")
.EncodeToStream(destinationFile.OpenWrite(), true, new GifEncoder())
.Finish().InProcessAsync();
```

Input file:

![43612_right](https://github.com/user-attachments/assets/74ee5fbb-65fd-4953-8922-442ba670122c)

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the ImageJob, ResizerCommands, trim.threshold=50, and GifEncoder example using the provided input GIF. Start by examining animated-frame handling around trimming and resizing, then verify that the output frames no longer bounce while trim.threshold remains effective.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, rust
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.