1from PIL import Image
2
3# Image.open() can also open other image types
4img = Image.open("some_random_image.jpg")
5# WIDTH and HEIGHT are integers
6resized_img = img.resize((WIDTH, HEIGHT))
7resized_img.save("resized_image.jpg")
1from PIL import Image
2# set the base width of the result
3basewidth = 300
4img = Image.open('somepic.jpg')
5# determining the height ratio
6wpercent = (basewidth/float(img.size[0]))
7hsize = int((float(img.size[1])*float(wpercent)))
8# resize image and save
9img = img.resize((basewidth,hsize), Image.ANTIALIAS)
10img.save('sompic.jpg')
1size = 7016, 4961
2im = Image.open("my_image.png")
3im_resized = im.resize(size, Image.ANTIALIAS)
4im_resized.save("my_image_resized.png", "PNG")