Gra*_*gon 7 python resize transform python-imaging-library
我无法让PIL放大图像.大图像缩小得很好,但小图像不会变大.
# get the ratio of the change in height of this image using the
# by dividing the height of the first image
s = h / float(image.size[1])
# calculate the change in dimension of the new image
new_size = tuple([int(x*s) for x in image.size])
# if this image height is larger than the image we are sizing to
if image.size[1] > h:
# make a thumbnail of the image using the new image size
image.thumbnail(new_size)
by = "thumbnailed"
# add the image to the images list
new_images.append(image)
else:
# otherwise try to blow up the image - doesn't work
new_image = image.resize(new_size)
new_images.append(new_image)
by = "resized"
logging.debug("image %s from: %s to %s" % (by, str(image.size), str(new_size)))
Run Code Online (Sandbox Code Playgroud)
Gra*_*gon 17
对于阅读此内容的人来说,遇到同样的问题 - 在另一台机器上试试.我得到了两个
im = im.resize(size_tuple)
Run Code Online (Sandbox Code Playgroud)
和
im = im.transform(size_tuple, Image.EXTENT, (x1,y1,x2,y2)
Run Code Online (Sandbox Code Playgroud)
正确调整文件大小.我的服务器上的python安装一定有问题.在我的本地机器上工作正常.
| 归档时间: |
|
| 查看次数: |
17762 次 |
| 最近记录: |