Python中可以使用PIL库(Pillow)来实现图像的旋转和缩放功能。下面是一个示例代码:
from PIL import Image# 打开图像文件image = Image.open('example.jpg')# 旋转图像rotated_image = image.rotate(45) # 旋转45度# 缩放图像resized_image = image.resize((200, 200)) # 缩放到200x200的大小# 显示图像rotated_image.show()resized_image.show()# 保存图像rotated_image.save('rotated_image.jpg')resized_image.save('resized_image.jpg')上面的代码中,首先使用Image.open()方法打开一个图像文件,然后分别使用rotate()方法和resize()方法来对图像进行旋转和缩放操作。最后使用show()方法显示处理后的图像,并使用save()方法保存处理后的图像。




