1from PIL import Image
2image = Image.open("path/.../image.png")
3image = image.resize((500,500),Image.ANTIALIAS)
4image.save(fp="newimage.png")
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')
1from PIL import Image
2from resizeimage import resizeimage
3
4fd_img = open('test-image.jpeg', 'r')
5img = Image.open(fd_img)
6img = resizeimage.resize_cover(img, [200, 100])
7img.save('test-image-cover.jpeg', img.format)
8fd_img.close()
9
1from PIL import Image
2
3from resizeimage import resizeimage
4
5
6with open('test-image.jpeg', 'r+b') as f:
7 with Image.open(f) as image:
8 cover = resizeimage.resize_cover(image, [200, 100])
9 cover.save('test-image-cover.jpeg', image.format)
10