Re: S3Storage.py and Thumbnails using PIL (IOError / cannot identify image file)

2008-12-22 Thread Merrick
I am always amazed by the support here, thank you. After seeing Brian's code I switched resize_image() to be a model method and then I switched from saving the form to saving the profile profile = request.user.get_profile() profile.save_picture(pform.cleaned_data['picture'].read()) instead of

Re: S3Storage.py and Thumbnails using PIL (IOError / cannot identify image file)

2008-12-22 Thread brianmac44
With my code, what are you using as "content"? I'm using: form.cleaned_data['source'].read() So my code looks something like this: PHOTO_MEDIUM_SIZE = 400,400 source_image = form.cleaned_data['source'].read() resized_image = resize_photo(source_image,PHOTO_MEDIUM_SIZE))

Re: S3Storage.py and Thumbnails using PIL (IOError / cannot identify image file)

2008-12-22 Thread Merrick
I got the same result with brianmac44's code. I also verified that the my resize_image() works when opening the file from the local filesystem - so I am somehow not passing the file in a manner that Image.open likes. On Dec 22, 4:45 am, brianmac44 wrote: > I had the same

Re: S3Storage.py and Thumbnails using PIL (IOError / cannot identify image file)

2008-12-22 Thread brianmac44
I had the same problem two weeks ago. This is what I wrote: def resize_photo(self,content,size): img = Image.open(ContentFile(content)) img.thumbnail(size, Image.ANTIALIAS) io = StringIO.StringIO() img.save(io, 'PNG') return ContentFile(io.getvalue()) Hope this helps.

Re: S3Storage.py and Thumbnails using PIL (IOError / cannot identify image file)

2008-12-22 Thread Merrick
Thank you I tried that and I still get the same error. I spent a little more time looking at PIL / Image.py and cleaning up the code. From what I can tell the Image.open method is having trouble with what I am passing to it. def resize_image(file, size=(50, 50)): from PIL import Image

Re: S3Storage.py and Thumbnails using PIL (IOError / cannot identify image file)

2008-12-21 Thread j...@zigzap.com
>From what I can tell your not wrapping the thumbnail file in ContentFile your just returning the raw file from the string IO. To use the the ImageField django provides you must provide it with a file that is in a special wrapper called ContentFile. I would suggest trying this: from

S3Storage.py and Thumbnails using PIL (IOError / cannot identify image file)

2008-12-19 Thread Merrick
I setup S3Storage as my default storage and can successfully upload images to S3 without overriding save on my profile_update below. Right now, when I submit a form with an image I get the original image uploaded in my S3 bucket not a thumbnail and an IO Error - "cannot identify image file" -