Skip to content

Commit

Permalink
fix image format
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Oct 30, 2017
1 parent c81dd69 commit 8759042
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ensae_projects/hackathon/image_helper.py
Expand Up @@ -38,9 +38,10 @@ def resize_image(filename_or_bytes, maxdim=512, dest=None, format=None):
if new_size == img.size:
return filename_or_bytes
else:
mapping = {'jpg': 'jpeg'}
img = img.resize(new_size)
st = BytesIO()
img.save(st, format=format.lower())
img.save(st, format=mapping.get(format.lower(), format))
return st.getvalue()
else:
raise TypeError("Unexpected type '{0}'".format(
Expand Down

0 comments on commit 8759042

Please sign in to comment.