Python、PIL、作物问题
似乎无法使裁剪正常工作,问题是,它裁剪了尺寸正确的区域,但总是从左上角 (0, 0),而不是从我传递的坐标开始。
image = Image.open(input)
region = image.crop((1000,400,2000,600)
region.save(output)
在 PIL 的 image.py 中,方法 _ImageCrop 我已经打印出来了..:
print x0, y0, x1, y1
self.__crop = x0, y0, x1, y1
值似乎是正确的。
输入是尺寸为 1600x2390 的 JPEG 图像。
Python版本:2.5, PIL 版本:1.1.6
有什么建议吗? 谢谢
Can't seem to get crop working correctly, problem is, it crops a region of correct dimensions, but always from top left corner (0, 0), instead of from my passed coordinates.
image = Image.open(input)
region = image.crop((1000,400,2000,600)
region.save(output)
In image.py from PIL, method _ImageCrop I've printed out.. :
print x0, y0, x1, y1
self.__crop = x0, y0, x1, y1
Values seem to be correct.
Input is a JPEG image of size 1600x2390.
Python version: 2.5,
PIL version: 1.1.6
Any suggestions? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
适用于我:Python 2.6.1、PIL 1.1.6、尺寸为 2020x1338 像素的 JPEG。
您确定您指的是 1600x2390 而不是 2390x1600 的 JPEG 吗? (1000,400,2000,600)框尺寸超出了1600宽图像的尺寸; 如果我尝试这样做,我会在相交区域之外得到垃圾数据。
Works For Me: Python 2.6.1, PIL 1.1.6, JPEG of size 2020x1338 pixels.
Are you sure you mean a JPEG of 1600x2390 and not 2390x1600? The (1000,400,2000,600) box dimensions are outside the size of a 1600-wide image; if I try this I get garbage data outside the intersecting area.
:
…………
接下来我要做的是
或者如果你过去不喜欢用PNG:
I`m do next:
....
.....
or if you wont as PNG past use: