Пример #1
0
 def save(self, commit=True):
     if "min_avatar" in self.changed_data:
         if self.instance.id:
             juror = Juror.objects.get(pk=self.instance.id)
             if juror.min_avatar:
                 juror.min_avatar.delete()
         self.instance.min_avatar = thumb_crop_img(Image.open(self.instance.min_avatar.file), 150, 150)
     return super(JurorForm, self).save(commit)
Пример #2
0
 def make_thumbs(self):
     img = Image.open(self.object.original_file.file).copy()
     img = img.convert('RGB')
     self.object.original_file.file.seek(0)
     self.object.image = thumb_img(img, 938)
     self.object.thumbnail = thumb_crop_img(img, width=190, height=123)
     self.object.icon = thumb_img(img, 60)
     del img
     self.object.save()