Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

handling image files django aws

from django.core.files.storage import default_storage as storage

import io

    if self.image:
      m = storage.open(self.image.name, 'rb')
           
      # img = Image.open(self.image)
      img = Image.open(m)

      if img.height > 600 or img.width > 600:
          output_size = (600, 600)
          img.thumbnail(output_size)
          img.point(lambda i: i * 2)
          # img.save(self.image.path)
          sfile = io.BytesIO()
          img.save(sfile, format='JPEG')
          m.close()
 
PREVIOUS NEXT
Tagged: #handling #image #files #django #aws
ADD COMMENT
Topic
Name
5+7 =