0

I am trying to resize an image by half and show it. Here is the code:

from PIL import Image

image0 = Image.open("cwu_logo0.jpg")

image0Width = image0.width
image0Height = image0.height

print(image0Width)
print(image0Height)

image0Resized = image0.resize(image0Width/2, image0Height/2)
image0Resized.show()

An error occurs when I run this code, I have trouble understanding it:

ValueError: Unknown resampling filter (77.0). Use Image.NEAREST (0), Image.LANCZOS (1), Image.BILINEAR (2), Image.BICUBIC (3), Image.BOX (4) or Image.HAMMING (5)

All help is appreciated.

1 Answers1

0
from PIL import Image

img = Image.open('/your image path/image.jpg') # image extension *.png,*.jpg
new_width  = 200
new_height = 300
img = img.resize((new_width, new_height), Image.ANTIALIAS)
img.save('output image name.png')

Referenece:- How do I resize an image using PIL and maintain its aspect ratio?

Abhishek Rai
  • 2,159
  • 3
  • 18
  • 38