2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 23:31:52 +00:00
troggle/imagekit/utils.py

16 lines
338 B
Python
Raw Normal View History

""" ImageKit utility functions """
import tempfile
def img_to_fobj(img, format, **kwargs):
tmp = tempfile.TemporaryFile()
if format != 'JPEG':
try:
img.save(tmp, format, **kwargs)
return
except KeyError:
pass
img.save(tmp, format, **kwargs)
tmp.seek(0)
return tmp