def _make_concatenation(self): """ depending on activated flags different combination of scripts is called """ file_names = self.lstbox.get(0, tk.END) if len(file_names) < 2: return image_list = [Image.open(e) for e in file_names] if self.bs_resize.variable: if self.bs_concat.variable: max_width = MergerScripts.find_max_width(image_list) image_list = MergerScripts.resize_all_tomax(image_list, max_width, Image, is_vertical=True) else: max_height = MergerScripts.find_max_height(image_list) image_list = MergerScripts.resize_all_tomax(image_list, max_height, Image, is_vertical=False) if self.bs_concat.variable: result_image = MergerScripts.concatenate_v(image_list, self.bg_color, Image) else: result_image = MergerScripts.concatenate_h(image_list, self.bg_color, Image) _path = self.direntry.variable _path = MergerScripts.make_default_concatenation_path(_path) self.direntry.variable = _path result_image.save(f'{self.direntry.variable}', 'PNG')
def test_concatenate_v(self): expected = 270 actual = MergerScripts.concatenate_v(self.images, 'white', Image).height assert expected == actual