Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

save pillow image to database django

# The crop function looks like this:

from PIL import Image

from django.core.files.base import ContentFile

def cropper(original_image, crop_coords):
      img_io = StringIO.StringIO()
      original_image = Image.open(original_image)
      cropped_img = original_image.crop((0, 0, 165, 165))
      cropped_img.save(img_io, format='JPEG', quality=100)
      img_content = ContentFile(img_io.getvalue(), 'img5.jpg')
      return img_content
Comment

PREVIOUS NEXT
Code Example
Python :: how to create barcode in python 
Python :: opening files in python 
Python :: self in python 
Python :: comment out multiple lines in python 
Python :: how to append in dictionary in python 
Python :: pandas selection row/columns 
Python :: python generate html 
Python :: Neuraal Netwerk python text 
Python :: BaseSSHTunnelForwarderError: Could not establish session to SSH gateway 
Python :: Check and Install appropriate ChromeDriver Version for Selenium Using Python 
Python :: django abstractuser 
Python :: python remove by index 
Python :: how to remove an element from dictionary using his value python 
Python :: how to read first column of csv intro a list python 
Python :: how to stop thread python 
Python :: how to add reaction by message id in discord.py 
Python :: request download file 
Python :: how to generate random number in python 
Python :: tree python 
Python :: download pdf python 
Python :: python math functions 
Python :: converting datatypes 
Python :: Disctionary to Array 
Python :: python merge strings 
Python :: pandas series example 
Python :: dict get value by index 
Python :: django unique validator 
Python :: python while loop break 
Python :: python os.path.join 
Python :: numpy get index of list of values 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =