from PIL import Image # Image.open() can also open other image types img = Image.open("some_random_image.jpg") # WIDTH and HEIGHT are integers resized_img = img.resize((WIDTH, HEIGHT)) resized_img.save("resized_image.jpg")
Here is what the above code is Doing:
1. Opening an image with Image.open()
2. Resizing the image with img.resize()
3. Saving the image with resized_img.save()