【发布时间】:2017-12-11 14:41:13
【问题描述】:
尝试使用以下方法调整我的图片大小(重量 > 100 MB):
>>> from PIL import Image
>>> image = Image.open(path_to_the_file)
>>> new_image = image.resize((200, 200))
并收到 ValueError: tile cannot extend outside image.
原图尺寸为
>>> image.size
>>> (4922, 3707)
我在做缩略图、旋转等时收到同样的错误。
我做错了什么?
编辑: 使用 ImageMagic 检查图像:
$ identify file.tif
file.tif[0] TIFF 4922x3707 4922x3707+0+0 32-bit Grayscale Gray 31.23MB 0.000u 0:00.009
file.tif[1] TIFF 2461x1854 2461x1854+0+0 32-bit Grayscale Gray 31.23MB 0.000u 0:00.000
filetif[2] TIFF 1231x927 1231x927+0+0 32-bit Grayscale Gray 31.23MB 0.000u 0:00.000
file.tif[3] TIFF 616x464 616x464+0+0 32-bit Grayscale Gray 31.23MB 0.000u 0:00.000
file.tif[4] TIFF 308x232 308x232+0+0 32-bit Grayscale Gray 31.23MB 0.000u 0:00.000
file.tif[5] TIFF 154x116 154x116+0+0 32-bit Grayscale Gray 31.23MB 0.000u 0:00.000
identify: Unknown field with tag 33550 (0x830e) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/881.
identify: Unknown field with tag 33922 (0x8482) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/881.
identify: Unknown field with tag 34735 (0x87af) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/881.
identify: Unknown field with tag 34736 (0x87b0) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/881.
【问题讨论】:
-
您的 TIFF 图像是单帧吗?另外,您可以尝试使用
image.thumbnail((200, 200), Image.ANTIALIAS) -
@MartinEvans
Image.ANTIALIAS似乎没有列出Image.thumbnail()的重新采样选项。自 PIL 版本 2.7.0 起已重命名为Image.LANCZOS -
TIFF 图像为单波段。模式为 Float32
-
".. 在做缩略图、旋转等时" – 那么,您可以对您的图像进行任何操作吗?如果没有,那么 PIL 可能无法正确支持它。