Hi,
I am trying to write validator to resize my image before storing in DB
field.
class RESIZE_IMG(object):
def __init__(self, isThumb=False, error_message='unresizable'):
(self.isThumb, self.error_message) = (isThumb, error_message)
def __call__(self, value):
import Image
try:
im = Image.open(value.file)
# This print is OK. PIL recognize uploaded image
print im.size, im.format
im.resize((100, 100))
value.file.seek(0)
im.save(value.file, im.format)
return (value, None)
except Exception as e:
print 'resize exception:', e
return (value, self.error_message)
Script runs well but data in DB field is no image data. It can' t be
displayed by download function from default controller too.
Thanks for help.