i use mongodb and save file to gridfs
now i want edit images from gridfs …
i use this code
def thumbnail(file_obj):
import StringIO
from PIL import Image
im = StringIO.StringIO()
im.write(file_obj.raw_file)
im_ful = Image.open(im)
return im_ful.info
but pil said “cannot identify image file”
thats image also 😉
how can fix it
You need an
im.seek(0)before theImage.open(im)call. Otherwise PIL tries to read from the end of the file, gets no data, and fails.