Hello,
I am trying to resize image on save from the admin part of django.
My Model is:
class Artwork(models.Model):
file = models.ImageField(upload_to=UPLOAD_DIR,)
title = models.CharField(max_length=100)
def __unicode__(self):
return self.title
def save(self, size=(80, 80)):
super(Artwork, self).save()
if self.file:
filename = self.file
image = Image.open(filename)
image.thumbnail(size, Image.ANTIALIAS)
image.save(filename)
the problem is that I get the error message
'ImageFieldFile' object has no attribute '_mode'.
When I change
filename = self.file
to
filename = '/path/to/some/image/in/the/filesystem/
image.jpg' (hardcoded)
the image is resized without problems.
I think the problem is that I try to open an image that is not yet
stored in the UPLOAD_DIR, but that is only an assumption.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---