Search
 
SCRIPT & CODE EXAMPLE
 

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()
Comment

PREVIOUS NEXT
Code Example
Python :: safe password in python 
Python :: Creating a Tuple with Mixed Datatypes. 
Python :: pydantic model and ORM model 
Python :: python tkinter gui does not update until function completes 
Python :: how to remove all line in file python 
Python :: excel win32com select multiple cells in a row or column 
Python :: Python Tkinter Label Widget Syntax 
Python :: scrapping components of webpage 
Python :: how to combine sets using union() function 
Python :: python null check optional 
Python :: choose what items on python 
Python :: python Fibonacci series up to n 
Python :: python workbook.add_format in percentage 
Python :: flask-sqlalchemy inheritance 
Python :: python backtest 
Python :: metros para cm para mm 
Python :: Problem With This? 
Python :: how i make viribal inside a string in python 
Python :: linear plot 1D vector for x python 
Python :: how to reassign a key py 
Python :: Illustrate Different Set Operations 
Python :: create date range python 
Python :: the best ide for python 
Python :: transfer sound to hz with python 
Python :: get resource path python 
Python :: how to write a program that interacts with the terminal 
Python :: dataframeclient influxdb example 
Python :: using django celery 5.0 
Python :: extract a subpart of a matrix 
Python :: add tab to python output 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =