-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotateForShort.py
More file actions
21 lines (17 loc) · 845 Bytes
/
Copy pathRotateForShort.py
File metadata and controls
21 lines (17 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from PIL import Image
import os
def Rotate():
# Define the directory containing your images
input_directory = "images"
output_directory = "images" # Create this folder if it doesn't exist
# Iterate through the files in the input directory
for filename in os.listdir(input_directory):
if filename.endswith(('.jpg', '.jpeg', '.png', '.bmp', '.gif')): # Add more image formats as needed
input_path = os.path.join(input_directory, filename)
output_path = os.path.join(output_directory, filename)
# Open the image
img = Image.open(input_path)
# Rotate the image 90 degrees clockwise
rotated_img = img.rotate(-90, expand=True)
# Save the rotated image to the output directory
rotated_img.save(output_path)