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 _find_widthheight(self): """ runs through selected image list, \\ returns width and height in pixels """ self.bs_sizes.variable = False self.bs_sizes.strv.variable = self.bs_sizes.falsestr file_names = self.lstbox.get(0, tk.END) if not file_names: self.width_entry.variable = 'none' self.height_entry.variable = 'none' return image_list = [Image.open(e) for e in file_names] if self.bs_maxmin.variable: self.width_entry.variable = MergerScripts.find_max_width( image_list) self.height_entry.variable = MergerScripts.find_max_height( image_list) else: self.width_entry.variable = MergerScripts.find_min_width( image_list) self.height_entry.variable = MergerScripts.find_min_height( image_list)
def test_find_max_width(self): expected = 256 actual = MergerScripts.find_max_width(self.images) assert expected == actual