Let's now resize images by modifying their pixel dimensions and applying various filters for re-sampling.
ImageResizeExample.bmpfrom the Packt website. We will use this as the reference file to create scaled images. The original dimensions of
200 x 212pixels.
outPathstrings with the appropriate image path on your machine.
1 import Image 2 inPath = "C:\\images\\ImageResizeExample.jpg" 3 img = Image.open(inPath) 4 width , height = (160, 160) 5 size = (width, height) 6 foo = img.resize(size) 7 foo.show() 8 outPath = "C:\\images\\foo.jpg" 9 foo.save(outPath)