Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

SystemError: tile cannot extend outside image

def crop_center(pil_img, crop_width, crop_height):
    img_width, img_height = pil_img.size
    return pil_img.crop(((img_width - crop_width) // 2,
                         (img_height - crop_height) // 2,
                         (img_width + crop_width) // 2,
                         (img_height + crop_height) // 2))
                         
                         
im_new = crop_center(im, 300, 150)
im_new.save('img.jpg', quality=95)
Comment

PREVIOUS NEXT
Code Example
Python :: python how to count all elements in a list 
Python :: python format subprocess output 
Python :: how to define the name of your tkinter window 
Python :: ++ python 
Python :: Accessing elements from a Python Dictionary 
Python :: how to generate random numbers in python 
Python :: append value to numpy array 
Python :: python get list of file and time created 
Python :: python mode 
Python :: children beautiful soup 
Python :: unittest skip 
Python :: try catch python 
Python :: how to get the first key of a dictionary in python 
Python :: python stack 
Python :: fork function in python 
Python :: make zipfile from directory py 
Python :: convert list to dataframe 
Python :: python path to python executable 
Python :: read file contents python 
Python :: how to multiply a string in python 
Python :: pandas change dtype 
Python :: python 
Python :: python how to draw triangle 
Python :: run python.py file 
Python :: python create a pinging sound 
Python :: python read json file array 
Python :: how to downgrade python 3.9 to 3.8 
Python :: keyboardinterrupt python 
Python :: python print with 2 decimals 
Python :: python dictionary dynamic key 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =