python调整图像大小而不会丢失锐度 [英] python resize image without losing sharpness

查看:357
本文介绍了python调整图像大小而不会丢失锐度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

from PIL import Image
import sys
image = Image.open(sys.argv[1])

basewidth = 1200
img = image
wpercent = (basewidth / float(img.size[0]))
hsize = int((float(img.size[1]) * float(wpercent)))
img = img.resize((basewidth, hsize), Image.BICUBIC)
img.save('sompic1.jpg')

print "image to %s" % (str(img.size))

我想调整1200xauto的大小并且这不会失去任何比例图像必须保持其shartness等等。

i want to resize 1200xauto and this without losing any ratio so the image must keep its shartness etc etc.

但重新调整大小的图像会以某种方式在锐度中被破坏。我也使用 ANTIALIAS ,但没有变化。怎么可能不失去锐度?

but resized images are somehow destroyed in sharpness. I used ANTIALIAS also, but no change. how is it possible not to lose the sharpness?

原始图片:(600x450)

original image: (600x450)

新的(1200x630):

new one (1200x630):

推荐答案

您正在尝试将图片尺寸调整为比原尺寸更大的尺寸,这是正常的,您可以放松质量。

You are trying to resize an image to a larger size than the original, it is normal that you loose quality.

要将图像尺寸调整为更小的尺寸,您可以查看我创建的这个模块: python-image-resize

To resize you image to a smaller size, you may have a look at this module I created: python-image-resize

这篇关于python调整图像大小而不会丢失锐度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆