Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

save image to database using pillow 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 :: use a csv file on internet as an api in python 
Python :: plotly coordinates mapping 
Python :: python dictionary pop key 
Python :: imagefield django models 
Python :: default values python 
Python :: how to join tables in python 
Python :: while loops python 
Python :: word2vec python 
Python :: reading the JSON from a JSON object 
Python :: django override delete 
Python :: exclude first value of an array python 
Python :: print list in one line python 
Python :: print multiplication table python 
Python :: adfuller test in python 
Python :: readlines 
Python :: axios django post 
Python :: xml depth python 
Python :: binary tree in python 
Python :: python towers of hanoi recursive 
Python :: sort dict 
Python :: python for dummies 
Python :: how to convert a datatype to another 
Python :: numpy copy a array vertical 
Python :: how to find length of list python 
Python :: text classification 
Python :: python command line keyword arguments 
Python :: beautifulsoup get img alt 
Python :: how to improve accuracy of random forest classifier 
Python :: list in one line of text in python 
Python :: what are test cases in python 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =