By the way, I don't think the user should wait for this kind of heavy
load work (resizing images, waiting the response).

Try to use lazy or remote call after you saved the image. Give celery
a try: http://ask.github.com/celery/

-- 
Rafael Lopes
(11)6729-1897



On Mon, Mar 15, 2010 at 1:59 PM, When ideas fail
<andrewkenyon...@gmail.com> wrote:
> Turned out it was all up the pole, but have it working now. The
> validation to check the size did work though.
>
> On 15 Mar, 16:12, "ge...@aquarianhouse.com" <ge...@aquarianhouse.com>
> wrote:
>> well, something is missing, like
>>
>> def save(self, *args, **kwargs):
>>     #your code
>>
>> but in our case the form class should do the validation...
>>
>> On Mar 15, 5:07 pm, When ideas fail <andrewkenyon...@gmail.com> wrote:
>>
>> > Hello, I've been trying to create a save method which resizes an image
>> > if it is too large. Using pil this is what I have so far:
>>
>> > class Photo(models.Model):
>>
>> >     title = models.CharField(max_length=750)
>> >     photo = models.FileField(upload_to='full_size/')
>> >     alt = models.CharField(max_length=50, null=True, blank=True)
>>
>> >    # Save the photo in less than or equal to 800x600
>>
>> >         if image.size[0] > 800:
>> >             if image.size[1] > 600:
>> >                 #resize image if its too large
>> >                 MAX_SIZE = (800,600)
>> >                 if self.photo:
>> >                     filename = self.photo.path
>> >                     image = Image.open(filename)
>> >                     image.thumbnail(MAX_SIZE, Image.ANTIALIAS)
>> >                     image.save(filename)
>> >                 super(Photo, self).save()
>> >         else:
>> >             super(Photo, self).save()
>>
>> > but it doesn't seem to work. It doesn't produce any errors but the
>> > images are the same size that they where before. Could someone tell me
>> > what i'm doing wrong? Thanks
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to