根据位置对图片进行合并还原 :filename:图片 :location_list:图片位置
(self, filename, location_list)
| 124 | return bg_location_list, fullbg_location_list |
| 125 | |
| 126 | def get_merge_image(self, filename, location_list): |
| 127 | """ |
| 128 | 根据位置对图片进行合并还原 |
| 129 | :filename:图片 |
| 130 | :location_list:图片位置 |
| 131 | """ |
| 132 | im = image.open(filename) |
| 133 | new_im = image.new('RGB', (260,116)) |
| 134 | im_list_upper=[] |
| 135 | im_list_down=[] |
| 136 | |
| 137 | for location in location_list: |
| 138 | if location['y'] == -58: |
| 139 | im_list_upper.append(im.crop((abs(location['x']),58,abs(location['x']) + 10, 166))) |
| 140 | if location['y'] == 0: |
| 141 | im_list_down.append(im.crop((abs(location['x']),0,abs(location['x']) + 10, 58))) |
| 142 | |
| 143 | new_im = image.new('RGB', (260,116)) |
| 144 | |
| 145 | x_offset = 0 |
| 146 | for im in im_list_upper: |
| 147 | new_im.paste(im, (x_offset,0)) |
| 148 | x_offset += im.size[0] |
| 149 | |
| 150 | x_offset = 0 |
| 151 | for im in im_list_down: |
| 152 | new_im.paste(im, (x_offset,58)) |
| 153 | x_offset += im.size[0] |
| 154 | |
| 155 | new_im.save(filename) |
| 156 | |
| 157 | return new_im |
| 158 | |
| 159 | def get_merge_image(self, filename, location_list): |
| 160 | """ |