9951 explained code solutions for 126 technologies


python-pillowHow to create square thumbnail (cropped to fit)


from PIL import Image, ImageOps

im = Image.open('/var/www/examples/heroine.png')
im = ImageOps.fit(im, (100,100), Image.ANTIALIAS)

im.show()ctrl + c
PIL

import Pillow package modules

Image.open

open given image with Pillow

100,100

thumbnail square area width and height

ImageOps.fit(

fits an image into given area

.show()

displays resulting image