Resize an image

from PIL import Image

    image1 = Image.open(C:/MyDirectory/myimage.jpg")

#Use default resampling method
    image1 = image1.resize((160,300))       

#Specify resampling method
    image1 = image1.resize((160,300), Image.Resampling.NEAREST)

Options:

Image.NEAREST – use nearest neighbour
Image.BILINEAR – linear interpolation
Image.BICUBIC – cubic spline interpolation
Image.LANCZOS – a high-quality downsampling filter

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *