I'm trying to resize images while keeping aspect ratio. I use PIL's thumbnail method for this. I use Image.ANTIALIAS filter.
You can check my code here:
image = Image.open(design.design.path)
format = image.format
image = ImageOps.mirror(image)
new_size = (241, 241)
image.thumbnail(new_size, Image.ANTIALIAS)
image.save(response, format)
This code works perfectly however quality is lost after thumbnail. I can see it by zooming in on the saved image. I can see pixels at the corners of the image while I don't on the original image. This is seen even better when I print out resized image.
You can check out sample images here: http://imgur.com/a/ifZoU
Please tell me if you need anything else
resize
method rather than thethumbnail
method – James Kentresize
not preserve aspect ratio? You hardcode the aspect ratio here to 1:1, and that would also be the aspect ratio if you would useresize
. – physicalattractionresize
keeps the aspect ratio you give it, which can be deduced before you resize it. – physicalattraction