开发者

How use Gridfs of mongodb with PIL (Python Image Library)

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开发者_StackOverflow中文版.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 the Image.open(im) call. Otherwise PIL tries to read from the end of the file, gets no data, and fails.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜