Simplicity
Simplicity

Reputation: 48966

Resizing an image in Python using PIL

I'm trying to resize an image in Python, and did the following:

from PIL import Image
img = Image.open('1.jpg')
img.resize((300,200))
img.save('image','jpeg')

In the result, the image remains the same size. Why is that? What could I be missing?

Thanks.

Upvotes: 3

Views: 1413

Answers (1)

wim
wim

Reputation: 363314

Resize returns a new object, and you didn't assign it to anything. Use this instead:

img = img.resize((300,200))

Upvotes: 4

Related Questions