code: def generate(self, save=True):
          
          stretched_photo, crop_box = self._generate_img()
  
          # set crop_box to (0,0,0,0) if photo not cropped
          if not crop_box:
              crop_box = 0, 0, 0, 0
  
          self.crop_left, self.crop_top, right, bottom = crop_box
          self.crop_width = right - self.crop_left
          self.crop_height = bottom - self.crop_top
  
          self.width, self.height = stretched_photo.size
  
          f = StringIO()
          imgf = (self.photo._get_image().format or
                  Image.EXTENSION[path.splitext(self.photo.image.name)[1]])
  
          stretched_photo.save(f, format=imgf, quality=self.format.resample_quality)
          f.seek(0)
  
          self.image.save(self.file(), ContentFile(f.read()), save)
docs: Generates photo file in current format.
  
          If ``save`` is ``True``, file is saved too.