-
-
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
GIF images incorrectly converted to RGB #434
Comments
No the problem here lies in the automatic P conversion on save. #405 seems to change the result, at least my bugged image looks different but it doesn't solve this problem. |
We can remove the "feature" maintaining the old palette but it bloats the result file. I'm checking how to solve it properly and I'm currently stumbling across the optimization. |
After going through the code I think the best thing to do would be to revert the offending commit for now. The biggest issue I found is that it's not safe to reuse the original palette after calling I think a full solution to reuse the palette would need to address it during the quantization phase of the conversion, limiting the possible colors to the ones already on the palette. But it seems a much more complex thing to do. |
Please try https://github.com/d-schmidt/Pillow/commit/ac6a731bb905a2dc591a921df2b421c7f28dd597 new result: from PIL import Image
f = open("testbild/test.colors.gif", "rb")
i = Image.open(f)
i.save("test1.gif")
i.save("test2.gif") # check optimization result
i = i.convert("RGB")
i.save("test3.gif") # check automatic P conversion |
I think moving |
It is there to prevent the gif lib from saving the complete WEB gif palette if you just open and save a new gif. I don''t know yet why it is done at all. Imo it should use the loaded palette from the file. Will put some more time into it tomorrow. |
Or next year. This is not forgotten but I'm on a tight schedule atm. |
Now targeting 2.4.0 |
After git bisecting the code I found that starting from commit b9ab3f5 there is a issue when converting GIFs from "P" format to either "RGB" or "RGBA".
In this case, pillow generates a black and white only image as it can be seen further down.
I'll try to understand what's happening and make a pull request latter.
This little snippet shows a way to reproduce it:
Result:
Expected:
cc: commit author @d-schmidt
The text was updated successfully, but these errors were encountered: