From 7e5491cc3edbc62f85229beca36a9e3602ec9ad4 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Tue, 8 Nov 2011 20:53:48 -0500 Subject: [PATCH] Reset file pointer before opening image. Fixes #47 --- imagekit/utils.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/imagekit/utils.py b/imagekit/utils.py index 1971e0d..deadbbd 100644 --- a/imagekit/utils.py +++ b/imagekit/utils.py @@ -1,4 +1,3 @@ -import os import tempfile import types @@ -35,11 +34,7 @@ def get_spec_files(instance): def open_image(target): - if hasattr(target, 'mode') and 'w' in target.mode and os.path.exists(target.name): - # target is a file like object with write mode enabled - # PIL will zero this file out and then give and IO error - # instead just pass PIL the path - target = target.name + target.seek(0) img = Image.open(target) img.copy = types.MethodType(_wrap_copy(img.copy), img, img.__class__) return img