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
答案 0 :(得分:1)
Image.save为您提供了选项:
img.save(fpath, 'image/png', quality=100, optimize=True)
答案 1 :(得分:0)
如果您正在制作基于像素的图像的缩略图,当然您会失去质量。重新调整这种图像(与矢量图像相对)只是简单地抛弃信息 - 没有办法恢复它。
如果您需要以完整尺寸查看图像,则必须保留原始图像,并将缩小版本仅显示在需要的位置 - 将原始图像用于其他所有图像。