resize photos
This commit is contained in:
parent
af72b86197
commit
3f5e2e93a3
12
resize_photos.py
Normal file
12
resize_photos.py
Normal file
@ -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)
|
Loading…
x
Reference in New Issue
Block a user