Closed maltelau closed 5 years ago
Thanks for the PR. I'll test this when I get a chance to do so; I've encountered issues with RGBA images before but was relatively sure I had fixed it.
No problem :)
Pillow used to just ignore alpha channels when saving to jpeg, but it's been deprecated as a warning since 3.4 and as an error since 4.2 (https://pillow.readthedocs.io/en/4.1.x/releasenotes/3.4.0.html#deprecation-warning-when-saving-jpegs). Current version from the ubuntu package python-pil is 5.1
Unsure why it didn't credit you, but I did merge your code into v4 work. Thanks for your contribution.
When png images have an alpha layer, they can retain them in RGBA mode even though we ask for RGB mode. This causes img.save(..., "JPEG") to fail with IOError("cannot write mode RGBA as JPEG"). This commit layers RGBA images on top of a black background before removing the alpha channel and converting to RGB.
Example image that used to fail: https://i.redd.it/gnro5oykh1821.png Issue in Pillow: python-pillow/Pillow#2609 StackOverflow solution: http://stackoverflow.com/a/9459208/284318