I asked a relative question previously, regarding pillow
.
Python Pillow: Make image progressive before sending to 3rd party server
Just to extend this, How can I achive the progressiveness
into the image when I am uploading an image and storing it on the sever?
Models.py
class Blog(models.Model):
banner = models.FileField("banner", upload_to='blog_banner', help_text='Upload blog banner', blank=True, null=True)
Forms.py
def clean(self):
data = self.cleaned_data
banner = data['banner']
# Check and make banner image progressive
if not Utils.is_progressive_img(banner):
data['banner'] = Utils.make_progressive_img(banner)
Progressive Method
img = Image.open(source)
progressive_img = StringIO()
img.save(progressive_img, "JPEG", quality=80, optimize=True, progressive=True)
in forms.py
when i save the the blog post i see the following error and I know this is due the the format of StringIO()
Error
AttributeError at /blog/create/
StringIO instance has no attribute '_committed'