苹果手机拍摄的照片和安卓手机拍摄图片混合作为目标检测或语义分割数据集,需要将苹果手机拍摄的图片进行顺时针旋转90度,然后在用标记软件进行标记

本文介绍了一个使用Python的os和PIL库来读取、旋转JPG图片并保存到指定输出文件夹的脚本,展示了如何在images_folder中对所有.jpg文件执行90度顺时针旋转的操作。
摘要由CSDN通过智能技术生成
import os
from PIL import Image

def rotate_images(images_folder, output_folder):
    # Process each file in the images folder
    for image_file in os.listdir(images_folder):
        if image_file.endswith('.jpg'):
            image_path = os.path.join(images_folder, image_file)
            # Load and rotate the image
            image = Image.open(image_path)
            rotated_image = image.rotate(-90, expand=True)  # Rotate clockwise by 90 degrees

            # Save the rotated image
            output_image_path = os.path.join(output_folder, image_file)
            rotated_image.save(output_image_path,quality=99)

# Set the paths to your image and output folders
# images_folder = 'E:\\ios_picture2'
images_folder = 'E:\\ios_picture2'
output_folder = 'D:\\2024-3-21_ios_add\\aaa'

# Rotate images in the folder
rotate_images(images_folder, output_folder)

print("Processing completed.")
  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值