Masukkan gambar yang dipotong di folder nama gambar asli Python

filepath = '/some/file/path/Frames/'

for filename in os.listdir(filepath):
    if "." not in filename:
        continue
    ending = filename.split(".")[1]
    if ending not in ["jpg", "gif", "png"]:
        continue

    try:
        image = Image.open(os.path.join(filepath, filename))
    except IOError as e:
        print("Problem Opening", filepath, ":", e)
        continue

    image = image.crop((535, 40, 600, 90))

    name, extension = os.path.splitext(filename)
    print(name + '_cropped.jpg')
    image.save(os.path.join('/some/file/path/Frames/Cropped', name + '_cropped.jpg'))
Said HR