def save(self):
super(Image, self).save()
im = Image.open( self.get_image_filename() ) #this fails
It looks like <self> never contains any significant information, before
and after the save.
I tried initializing the last object placed in the database but like
above, this variable has no real information:
def save(self):
super(Image, self).save()
i = Image.objects.order_by('-id')[0]
im = Image.open( i.get_image_filename() )
Is there anyway to get this logic implemented by overriding the save
method or do I have to extend the ImageField class like others
(http://www.verdjn.com/browser/verdjnlib/fields/photofield.py) have?
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.