Bre*_*ttJ 3 python python-imaging-library
我很好奇为什么我的图像不旋转,它每次都处于相同的位置。
img = Image.open(r'C:\Users\Brett\Downloads\testing.jpg')
exif_data = {
TAGS[k]: v
for k, v in img._getexif().items()
if k in TAGS
}
print(exif_data['Orientation'])
Run Code Online (Sandbox Code Playgroud)
输出“6”
无论我告诉图像旋转多少度,它最终都会处于相同的位置。
if exif_data['Orientation'] == 6:
img.rotate(90)
Run Code Online (Sandbox Code Playgroud)
或者
if exif_data['Orientation'] == 6:
img.rotate(270)
Run Code Online (Sandbox Code Playgroud)
或者
if exif_data['Orientation'] == 6:
img.rotate(180)
Run Code Online (Sandbox Code Playgroud)
我总是得到逆时针旋转 90 度的图像。我做错了什么吗?
来自(文档)
Image.rotate(角度、重新采样=0、展开=0、中心=无、平移=无)
返回该图像的旋转副本。此方法返回该图像的副本,绕其中心逆时针旋转给定的度数。
图像未就位旋转。您需要存储从返回的图像rotate()。也许是这样的:
if exif_data['Orientation'] == 6:
new_image = img.rotate(180)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5864 次 |
| 最近记录: |