from PIL import Image
import os
import PIL
import glob
from pathlib import Path
fixed_height = 1600 # your new heigt size
path_folder = '/Volumes/chumbertoc/Codeandote/proyectos/boen/imgs/productos/MASCARILLA DE CAJITA/' # your new folder source
for path in Path(path_folder).iterdir():
if path.name.lower().endswith(('.png', '.jpg', '.jpeg', '.tiff', '.bmp', '.gif')):
print(image)
image = Image.open(path_folder+path.name)
height_percent = (fixed_height / float(image.size[1]))
width_size = int((float(image.size[0]) * float(height_percent)))
image = image.resize((width_size, fixed_height), PIL.Image.NEAREST)
image.save(path.name,optimize=True,quality=30) # output in code path
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.