[530] from IRC worked with me to figure out what's going on.
Apparently save() is getting called twice, the first time saves the
object, the second time applies the the uploaded directory. We need to
check to see if self.image exists before trying to create thumbnails.
Here's a simple version of the script.
imageFolders = {'thumb': (100,75), 'small': (240,180), 'medium':
(500,375)}
super(StoryImage, self).save() # Call the "real" save() method.
if self.image:
im = Image.open(self.get_image_filename())
for dir in imageFolders:
copy = im.copy()
copy.thumbnail(self.imageFolders[dir], Image.ANTIALIAS)
copy.save(self.imagePath+dir+'/'+imagename, 'JPEG', quality=85)
It would probably be smart to remove the old images if you decide to
edit a currently saved image. I am testing to see how this works by
calling os.remove(self.get_image_filename()) prior to calling
super.save()
Any more information on this subject would be helpful.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---