























from PIL import Image import numpy as np import os import hashlib input_folder = "D:/tmp/luping/shots/" output_folder = "D:/tmp/luping/shots_clean/" os.makedirs(output_folder, exist_ok=True) bottom_crop = 600 # 要裁掉的底部高度 for file in sorted(os.listdir(input_folder)): if not file.lower().endswith((".png", ".jpg", ".jpeg")): continue path = os.path.join(input_folder, file) img = Image.open(path).convert("L") # 灰度 w, h = img.size # 裁剪底部空白 bottom = h - bottom_crop crop = img.crop((0, 60, w, bottom)) # 保留顶部到 bottom (左, 上, 右, 下) # 保存 crop.save(os.path.join(output_folder, file)) print("完成!已裁剪底部空白")
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。