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 )
相关推荐
feixing_fx10 分钟前
解构与展开:可读性和性能的取舍
开发语言·前端·javascript·前端框架
小飞在努力29 分钟前
【实现负载均匀在线判题③】从零散模块到统一,编译运行全链路封装
c语言·开发语言·c++·笔记
Logintern0943 分钟前
deep agents 多智能体模式——规划与委派
python·langchain
2601_967980112 小时前
Python 办公自动化合集 ⑰:Excel自动计算——总和/平均分/最大值
python·pycharm·办公自动化·数据处理·excel自动计算
饮水桶_T4 小时前
C++ stack & queue复习笔记
开发语言·笔记·算法
炸膛坦客4 小时前
单片机/C/C++八股:(三十四)C 语言函数参数入栈顺序
c语言·开发语言·c++
databook4 小时前
时间序列预测,模型换了一圈为什么没变好
python·数据分析
reasonsummer5 小时前
【教学类-07-17】20261119大3班破译电话号码HTML实际操作(添加“跳过按钮”和“返回按钮”在底部、增加“自编题目+解题”部分)
python·html
咖啡八杯5 小时前
LoginUser 适配器模式:适配 SysUser 到 UserDetails
java·开发语言·后端·框架·适配器模式·若依
bufengwangluo6 小时前
企业上网行为管理:代理网关部署位置怎么选,策略怎么落
开发语言·php