我安装了Python的Pillow库,并尝试裁剪图片。
其他效果都很好(例如,缩略图、模糊图像等)。
每当我运行下面的代码时,都会收到以下错误:
tile cannot extend outside image
test_image = test_media.file
original = Image.open(test_image)
width, height = original.size # Get dimensions
left = width/2
top = height/2
right = width/2
bottom = height/2
cropped_example = original.crop((left, top, right, bottom))
cropped_example.show()
我使用了一个在PIL中找到的裁剪示例,因为我无法为Pillow找到类似的(我认为应该是相同的)。