MCPcopy Index your code
hub / github.com/wistbean/learn_python3_spider / mergy_Image

Function mergy_Image

fuck_bilibili_captcha.py:18–58  ·  view source on GitHub ↗

将原始图片进行合成 :param image_file: 图片文件 :param location_list: 图片位置 :return: 合成新的图片

(image_file, location_list)

Source from the content-addressed store, hash-verified

16
17
18def mergy_Image(image_file, location_list):
19 """
20 将原始图片进行合成
21 :param image_file: 图片文件
22 :param location_list: 图片位置
23 :return: 合成新的图片
24 """
25
26 # 存放上下部分的各个小块
27 upper_half_list = []
28 down_half_list = []
29
30 image = Image.open(image_file)
31
32 # 通过 y 的位置来判断是上半部分还是下半部分,然后切割
33 for location in location_list:
34 if location['y'] == -58:
35 # 间距为10,y:58-116
36 im = image.crop((abs(location['x']), 58, abs(location['x'])+10, 116))
37 upper_half_list.append(im)
38 if location['y'] == 0:
39 # 间距为10,y:0-58
40 im = image.crop((abs(location['x']), 0, abs(location['x']) + 10, 58))
41 down_half_list.append(im)
42
43 # 创建一张大小一样的图片
44 new_image = Image.new('RGB', (260, 116))
45
46 # 粘贴好上半部分 y坐标是从上到下(0-116)
47 offset = 0
48 for im in upper_half_list:
49 new_image.paste(im, (offset, 0))
50 offset += 10
51
52 # 粘贴好下半部分
53 offset = 0
54 for im in down_half_list:
55 new_image.paste(im, (offset, 58))
56 offset += 10
57
58 return new_image
59
60
61def get_distance(bg_Image, fullbg_Image):

Callers 1

recognize_codeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected