Re: Upload image file, resize using PIL, then save into ImageField - what to save to ImageField?

2010-03-19 Thread robinne
Thanks for all your replies. I ended up using sorl-thumbnail, which I had already installed, but I didn't think it kept aspect ratio of image because you are required to enter w and h for thumbnail image size using ThumbnailField. A quick test shows that it resizes and keeps same aspect ratio. So,

Re: Upload image file, resize using PIL, then save into ImageField - what to save to ImageField?

2010-03-19 Thread CrabbyPete
The Imagefile is just a pointer to file. Here is what I do to upload and resize an image. I hope it helps. file_to_open = settings.MEDIA_ROOT+'//profiles//'+ user.username+'-'+file.name fd = open(file_to_open, 'wb+') if file.multiple_chunks(): for chunk in file

Re: Upload image file, resize using PIL, then save into ImageField - what to save to ImageField?

2010-03-18 Thread Alex Robbins
I think Satchmo uses http://code.google.com/p/sorl-thumbnail/ I think it uses PIL underneath a layer of abstraction. That might work for you if you are just wanting to generate alternate versions of uploaded images. Alex On Mar 18, 12:10 am, robinne wrote: > I can save an uploaded image to a Fil

Re: Upload image file, resize using PIL, then save into ImageField - what to save to ImageField?

2010-03-18 Thread bruno desthuilliers
On Mar 18, 6:10 am, robinne wrote: > I can save an uploaded image to a FileField like this (where > "ProductFile" is a model) and "TempFile" is an ImageField: > > uploadedfile = request.FILES['uploadfile'] > ProductFile.objects.create(FileName=UploadDate=datetime.datetime.now(), > TempFile=uploade

Upload image file, resize using PIL, then save into ImageField - what to save to ImageField?

2010-03-17 Thread robinne
I can save an uploaded image to a FileField like this (where "ProductFile" is a model) and "TempFile" is an ImageField: uploadedfile = request.FILES['uploadfile'] ProductFile.objects.create(FileName=UploadDate=datetime.datetime.now(), TempFile=uploadedfile) But, how do I manipulate the image size