In this article, you’ll see how to resize an image in the PIL Python module. You can specify the width and height according to your requirement. In the following example, “cats.jpg” is the name of an image.
# Import the PIL library from PIL import Image # Read the image from location image = Image.open("C:\\AiHints\\cats.jpg") # Resize the image resized_image = image.resize((600, 300)) # width, height # Show the original image image.show() # Show the resized image resized_image.show()
Recommendation: Computer Vision: Models, Learning, and Inference Book