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

Gif image copyCrop not working properly #588

Open
longpp1994 opened this issue Nov 15, 2023 · 2 comments
Open

Gif image copyCrop not working properly #588

longpp1994 opened this issue Nov 15, 2023 · 2 comments

Comments

@longpp1994
Copy link

longpp1994 commented Nov 15, 2023

version: 4.1.3

void cropAndSaveImage({
  required int x,
  required int y,
  required int width,
  required int height,
  required String savePath,
  required String imagePath,
}) {
  final image = decodeImage(File(imagePath).readAsBytesSync());

  final cropImg = copyCrop(
    image!,
    x: x,
    y: y,
    width: width,
    height: height,
  );

  final file = File(savePath);
  file.createSync(recursive: true);
  file.writeAsBytesSync(encodeGif(cropImg));
}

origin gif
test

output gif
test_crop

It happens on some gif images,maybe it has something to do with the palette?

@brendan-duncan
Copy link
Owner

Does it happen without the copyCrop?
GIF is a horrible format, I wish it had died in the 90s like it was supposed to. Likely it's a per-frame palette issue. I had dome some work around that, but it looks like this is another edge case. I'll take a look whenever I can get a chance.

@longpp1994
Copy link
Author

I made a test, It looks like copyCrop is not the cause of that
btw i agree with your point on GIF XD

void decodeThenEncodeGif({
  required String imagePath,
  required String savePath,
}) {
  final image = decodeImage(File(imagePath).readAsBytesSync());
  final file = File(savePath);
  file.createSync(recursive: true);
  file.writeAsBytesSync(encodeGif(image!));
}

output:
test_crop

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

No branches or pull requests

2 participants