Skip to content

Commit 9c7c314

Browse files
committed
RGBA images need to be reduced to RGB before saving as JPEG
I tried uploading large (i.e. which need to be minified) PNG images with an alpha channel (RGBA) and this resulted in an error 'OSError: cannot write mode RGBA as JPEG This should fix this issue.
1 parent c16c0d4 commit 9c7c314

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

py/BO/Image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def dimensions_and_resize(
5858
image_to_write.height = im.size[1]
5959
# Generate a thumbnail if image is too large
6060
if (im.size[0] > max_dim) or (im.size[1] > max_dim):
61-
if im.mode == "P" or im.mode[0] == "I":
61+
if im.mode == "P" or im.mode[0] == "I" or im.mode == "RGBA":
6262
# (8-bit pixels, mapped to any other mode using a color palette)
6363
# from https://pillow.readthedocs.io/en/latest/handbook/concepts.html#modes
6464
# Tested using a PNG with palette

0 commit comments

Comments
 (0)