On Wed, Oct 26, 2011 at 9:06 PM, Swaroop Shankar V <swaroo...@gmail.com> wrote: > Hello All, > Am pretty new to Django. I am trying to create a form which will upload an > image and then enable the user to crop visually (using JCrop plugin). Am > not completely sure on how to implement this in Django. I am thinking of > first saving the uploaded image into the disk as a jpeg file and then load > and display the image as an overlay where the user can crop the image. I am > able to create a form with the image field and then am passing over > request.FILE to a function called handle_uploaded_image. Following is > my handle_uploaded_image function > def handle_uploaded_image(self, image): > """ > This function is to handle uploaded image file > """ > imageFile = Image.open(StringIO.StringIO(image.read())) > fileName = hashlib.md5(imageFile.getvalue()).hexdigest()+'.jpg' > Now i am kind of confused on how to convert the uploaded image into jpg > using PIL, and then saving into the disk. I had defined a field in my model > to save the image file name which is as follows: > class UserProfile(models.Model): > > avatar = models.ImageField(_('Avatar'),upload_to=settings.IMAGE_UPLOAD_PATH, > null=True) > > I did this based on the django documentation, but it tells something about > binding the form which am not able to correctly understand. Why do we need > to bind a form with image field. Also whats the use of giving upload_to in > model image field? Thanks in advance for any help. > Regards, > > Swaroop Shankar V >
http://www.pythonware.com/library/pil/handbook/introduction.htm The section 'Reading and Writing Images' should make this clear. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.