Created
May 13, 2021 21:38
-
-
Save c-neto/309d3b96e702d7f4812e5bd2221fa64e to your computer and use it in GitHub Desktop.
Crop mulit images files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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