Skip to content

Commit

Permalink
fix generating renditions for png images (#994)
Browse files Browse the repository at this point in the history
it's not possible to save rgba picture as jpg via PIL
  • Loading branch information
petrjasek committed Feb 27, 2020
1 parent 5c8ec5b commit f0aa070
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions newsroom/media_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
def store_image(image, filename=None, _id=None):
"""Store the image to GridFs or AWS S3"""
binary = io.BytesIO()
if image.mode != 'RGB':
image = image.convert('RGB')
image.save(binary, 'jpeg', quality=THUMBNAIL_QUALITY)
binary.seek(0)
media_id = app.media.put(binary, filename=filename, _id=_id, resource=ASSETS_RESOURCE, content_type='image/jpeg')
Expand Down

0 comments on commit f0aa070

Please sign in to comment.