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

The specific Gif file is loaded and saved as the wrong style. #2866

Open
4 tasks done
BAKAOLC opened this issue Jan 22, 2025 · 2 comments
Open
4 tasks done

The specific Gif file is loaded and saved as the wrong style. #2866

BAKAOLC opened this issue Jan 22, 2025 · 2 comments

Comments

@BAKAOLC
Copy link

BAKAOLC commented Jan 22, 2025

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

ImageSharp version

3.1.6

Other ImageSharp packages and versions

SixLabors.ImageSharp.Drawing 2.1.5

Environment (Operating system, version and so on)

macOS Sequoia 15.2

.NET Framework version

.net 9.0

Description

There are some specific compressed Gif files that are saved after being loaded that lose their differential rendering properties, resulting in black blocks in the image. But the original image renders fine without ImageSharp. However the image works fine in ImageSharp after it has been re-encoded by other software.

The result of the error looks like this:
2.gif

As well, how do I get the full frame image of the compressed Gif correctly in the code instead of the difference?

Steps to Reproduce

just load and save it.

using var image = await Image.LoadAsync<Rgba32>("1.gif");
await image.SaveAsync("2.gif");

Images

1.gif

@JimBobSquarePants
Copy link
Member

JimBobSquarePants commented Jan 22, 2025

What do you mean by compressed gifs?

The encoder only encodes the difference because otherwise you end up with massive gifs. There’s no way to turn that off.

@BAKAOLC
Copy link
Author

BAKAOLC commented Jan 24, 2025

Sorry for the long delay in replying.

What do you mean by compressed gifs?

The encoder only encodes the difference because otherwise you end up with massive gifs. There’s no way to turn that off.

I'm referring to gifs that only keep a record of the changed pixels.

After I ran a lot of tests, I figured out why I was asking the question. Using CloneFrame itself gives me the results I want, and the reason I'm asking is because I usually save as a png or gif, so it's getting the wrong results, and leading me to think that what this method gets would be the difference pixel map (instead of the full frame image)

This gif if I export it using CloneFrame and save it as a png, it will all show up as a pure empty image.

using var image = await Image.LoadAsync<Rgba32>("1.gif");
for (var i = 0; i < image.Frames.Count; i++)
{
    using var frameImage = image.Frames.CloneFrame(i);
    frameImage.Save($"frame-{i}.png");
}

Image

And if I store it in jpg format, it's correct, this image is the result I want.

using var image = await Image.LoadAsync<Rgba32>("1.gif");
for (var i = 0; i < image.Frames.Count; i++)
{
    using var frameImage = image.Frames.CloneFrame(i);
    frameImage.Save($"frame-{i}.jpg");
}

Image

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

No branches or pull requests

2 participants