from PIL import Image
import os

input_path = r"FireShot Capture 004 - 信用卡欺诈 -.png"
output_dir = r"split_20"
num_parts = 20

os.makedirs(output_dir, exist_ok=True)

img = Image.open(input_path)
w, h = img.size
part_h = h // num_parts

print("原图尺寸：", w, h)

for i in range(num_parts):
    top = i * part_h
    bottom = (i + 1) * part_h if i < num_parts - 1 else h
    crop = img.crop((0, top, w, bottom))
    out_path = os.path.join(output_dir, f"part_{i+1:02d}.png")
    crop.save(out_path)
    print("已保存：", out_path, crop.size)

print("完成")