Home > Software design >  How to resize image without losing pixel qualityin python?
How to resize image without losing pixel qualityin python?

Time:02-27

I have an 32x32 image. I resize it for 512x512 in python, quality and view of image is not same when I resize it in paint.

original image resized-with-paint resized-with-python

What is needed to add to have same result as Paint?

from PIL import Image
im=Image.open('1.png')
im=im.resize(512,512)
im.save('resized.png')

    

CodePudding user response:

Use:

im = im.resize((521,512), resample=Image.NEAREST)

for that effect.

  • Related