bash
'''
#Author :susocool
#Creattime:2024/5/25
#FileName:turn360
#Description: 会旋转指定的图像文件360度,并将每个旋转后的图像保存到指定目录,文件名以旋转角度命名。
'''
from PIL import Image
def rotate_and_save(image_path, output_dir) :
# 打开图像文件
image = Image.open (image_path)
# 旋转并保存图片
for angle in range ( 0, 361 ) :
rotated_image = image.rotate ( angle )
output_path = f"{output_dir}/rotated_{angle}.jpg"
rotated_image.save ( output_path )
print ( f"Saved image at angle {angle} to {output_path}" )
# 替换为你的图像文件路径
image_path = "C:\\Users\\tkdpl\\Desktop\\IMG\\miaomiao.png"
# 替换为你想要保存输出图像的目录
output_dir = "C:\\Users\\tkdpl\\Desktop\\IMG\\360"
rotate_and_save ( image_path, output_dir )