Python-图片旋转360,保存对应图片

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 )
相关推荐
devilnumber3 小时前
Java 递归算法 详解 + 核心要点 + 实战运用 + 避坑指南
java·开发语言·算法
大貔貅喝啤酒4 小时前
Python Requests库教程
自动化测试·python·requests库
copyer_xyf4 小时前
LangChain 调用 LLM
后端·python·agent
copyer_xyf5 小时前
Prompt 组织管理
后端·python·agent
asdfg12589635 小时前
JavaBean是什么?怎么理解?有什么用途?
java·开发语言
dsyyyyy11015 小时前
JavaScript变量
开发语言·javascript·ecmascript
shimly1234565 小时前
python3 uvicorn 是啥?
python
z落落6 小时前
C#WinForm 窗体切换与窗体传值(登录跳转案例)+WinForm 窗体传值(从上往下传、从下往上传)
开发语言·windows·c#
CTA量化套保6 小时前
期货量化程序 time.sleep 卡死:天勤单线程与 deadline 替代
python·区块链
allway26 小时前
How to Echo Multiline to a File in Bash [3 Methods]
开发语言·chrome·bash