Python使用PIL库对图片进行切割和合并
分隔后图片:
// Python使用PIL库对图片进行切割
// An highlighted block
def crop_image():
image = Image.open("../learn_file/file/sunflower.jpeg")
weight, height = image.size
print(image.size)
#分隔的图片大小
segment_width = 100
segment_height = 100
segment_width_num = weight // segment_width
segment_height_num = height // segment_height
print(segment_width_num, segment_height_num)
# left, top, right, bottom = 0, 0, 100, 100
# left, top, right, bottom = 100, 0, 200, 100
# left, top, right, bottom = 200, 0, 300, 100
# ......
# left, top, right, bottom = 1100, 0, 1200, 100
#left, right---->x
#top, bottom--