-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Animated gif displays frames incorrectly #1525
Comments
Just to check before going any further - you've mixed up left and right in your comments, yes? |
Oh, yeah @radarhere. Note to self: do not open issues while sleepy. |
Thanks for clarifying, and thanks for the link to the previous issue, very helpful. So, GIFs can have a 'disposal method', and one setting of this that each subsequent frame is to be pasted on top of a previous one, making the raw latter frame simply the difference of the image. Sounds like a good compression technique. So the second frame is an RGBA to be pasted onto the first one. The good news is that the GifImagePlugin is correctly working all of this out and performing those operations. The bad news is that it's the That's all I have for the moment, but it's a start. |
Okay! It's because the base image is P mode, whereas the mask is RGBA. Convert the base image to RGB, and it works fine. So that's how to get it working. I'm not quite sure what the best solution is. If the aim was to fix this from GifImagePlugin, then it would be simpler. However, I presume it is better to solve this for the The |
I'm sorry, I don't understand what you mean. Convert the
also, how do you save the second frame? I'm really sorry I kinda abandoned this, I looked at it and forgot. Then once I got to my problem again I remembered. |
If you adjust your Pillow installation according to the above diff, then your program should run correctly. That will solve your immediate problem. |
Thank you, but is there anyway to do it within the code so that people can use it without the fix. |
I don't know how to resolve the bug within the Pillow code. Hopefully this problem will be resolved by someone, and contributions are welcome if you have suggestions. I thought that you were seeking an immediate solution to your problem, and that was my attempt at one. |
I was, but my problem exists for my program that a lot of people use and I want it to be fixed for everyone without people having to apply a fix, I will continue to see if this can be fixed within pillow, maybe making an external paste method. Thank you so much for your help. I really appreciate it |
hi @radarhere You patch works, why didn't you merge it ? |
Hi. My patch works, but with two problems -
If you want to create a PR with the patch, to see if others agree with you that it should be merged, you're welcome to. |
This is still an issue |
👍 Having this issue as well but in a different way. I have a GIF with disposal method set to 1 as well. But the previous frame uses the global color table and the new frame uses a local color table. When pasting the new image on the previous image, the color table for the local color table is not preserved. |
@addisonElliott to keep tracking simple, I'd ask that you create a new issue for your problem, since it is not exactly the same as this one. |
Hi, @radarhere . I stumbled across the same issue and tried your workaround code. I am using PIL 5.2.0 in the simplest loop to show every frame. But it throws this error:
Also, only the first two frames can be shown correctly, so this leads me to think that PIL is now getting the palette from the previous frame and feeding it to the next frame when self._prev_im.paste(updated, self.dispose_extent, updated.convert('RGBA'))
# I added this following line
self._prev_im=self._prev_im.convert('P')
self.im = self._prev_im
self._prev_im = self.im.copy() And then every frame comes out as expected.
I don't think there's a bug with pasting a transparent image, since it's using the if self.mode != im.mode:
if self.mode != "RGB" or im.mode not in ("RGBA", "RGBa"):
im = im.convert(self.mode) So the updated area will be converted to the same mode as the frame(in this case, 'P'). This is probably the reason why transparency went missing. It's more like an incompatibility rather than a bug that can be fixed in the |
I've created PR #5857 to resolve this. |
I'm having the same exact problem as #634 but that issue was "fixed".
When I seperate the frames using
convert -coalesce animation.gif target.png
in ImageMagick, the frames come out looking perfect, but with pillow...The gif in question
The text was updated successfully, but these errors were encountered: