An existing installation of Python is required.
Before running the script, make sure that you have installed the required libraries
Before running the script, make sure that you have installed the required libraries
pip install Pillow
from PIL import Image
import os
# Folder path and target size (pixels), don't forget to adjust path
folder_path = "C:/Pictures/"
target_width = 267
target_height = 400
# Loop through all files in folder
for filename in os.listdir(folder_path):
# Check if it is a JPG file
if filename.endswith(".jpg"):
# Full path to file
file_path = os.path.join(folder_path, filename)
# Open the image
with Image.open(file_path) as img:
# Resize
img.thumbnail((target_width, target_height))
# Remove metadata
data = list(img.getdata())
img_without_meta = Image.new(img.mode, img.size)
img_without_meta.putdata(data)
# Save and overwrite image
img_without_meta.save(file_path)
Your opinion is important – please leave a comment!
0 Comments