From 3f5e2e93a3f8db2e4aa4c9add949a0e5c17f64c4 Mon Sep 17 00:00:00 2001 From: Martin Quarda Date: Thu, 9 May 2024 16:48:25 +0200 Subject: [PATCH] resize photos --- resize_photos.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 resize_photos.py diff --git a/resize_photos.py b/resize_photos.py new file mode 100644 index 0000000..f498e4c --- /dev/null +++ b/resize_photos.py @@ -0,0 +1,12 @@ +import glob +import PIL.Image + +photos = glob.glob('photos/*.jpg') + +for image in photos: + img = PIL.Image.open(image) + img.save(image.replace('.jpg', '.webp')) + ratio = 200/max(img.height, img.width) + img.resize((int(img.width * ratio), int(img.height * ratio))) + image = image.replace('photos/', 'photos/thumbnail/').replace('.jpg', '.webp') + img.save(image, quality=10, subsampling=2) \ No newline at end of file