Skip to content

Commit

Permalink
Fixed pillow image conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjoes committed Oct 16, 2019
1 parent b033918 commit ffae64d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion flask_admin/form/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ def _resize(self, image, size):
return image

def _save_image(self, image, path, format='JPEG'):
if image.mode not in ('RGB', 'RGBA'):
# New Pillow versions require RGB format for JPEGs
if format == 'JPEG':
image = image.convert('RGB')
elif image.mode not in ('RGB', 'RGBA'):
image = image.convert('RGBA')

with open(path, 'wb') as fp:
Expand Down

0 comments on commit ffae64d

Please sign in to comment.