tags:

views:

57

answers:

1
def create_thumbnail(f, width=200, height=100):
    im = Image.open(f)
    im.thumbnail((width, height), Image.ANTIALIAS)
    thumbnail_file = StringIO()
    im.save(thumbnail_file, 'JPEG')
    thumbnail_file.seek(0)
    return thumbnail_file

It seems that my error is "IOError: cannot identify image file"...based on my traceback log.

+2  A: 

The only thing I can think of is that you are running on Windows, in which case Image.open() will open a file handler but does not close it. (That behaviour does not occur on Linux/Unix - the file is closed by the end of your code, and it doesn't matter if it isn't anyway).

spookylukey
Found a solution.I did .read() before...and that messed up.you have to .seek(0) to go back to the first byte.
TIMEX