Skip to content

Instantly share code, notes, and snippets.

@c-neto
Created May 13, 2021 21:38
Show Gist options
  • Save c-neto/309d3b96e702d7f4812e5bd2221fa64e to your computer and use it in GitHub Desktop.
Save c-neto/309d3b96e702d7f4812e5bd2221fa64e to your computer and use it in GitHub Desktop.
Crop mulit images files
# rerquirements.txt
# pillow
from pathlib import Path
from PIL import Image
base_converted = Path('./converted')
base_path = Path('./images')
left = 0
top = 0
right = 752
bottom = 480
for path in base_path.glob('*'):
img = Image.open(path.resolve())
img_res = img.crop((left, top, right, bottom))
p = Path(base_converted, path.name)
img_res.save(p.resolve())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment