Answers for "how to know image size in pillow"

8

pil get image size

from PIL import Image

im = Image.open('whatever.png')
width, height = im.size
Posted by: Guest on April-01-2020
3

python pillow resize image

from PIL import Image
# set the base width of the result
basewidth = 300
img = Image.open('somepic.jpg')
# determining the height ratio
wpercent = (basewidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
# resize image and save
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
img.save('sompic.jpg')
Posted by: Guest on May-23-2020

Python Answers by Framework

Browse Popular Code Answers by Language