def load_image(self): self.reset_window_width_height() self.image_original = Image.open(self.image_path) self.image_original = exif_orientation.correct_image_orientation( self.image_original) self.top.title(self.image_path) self.create_thumbnail()
def create_image_buttons_mt(self, image_paths, mt_queue): for image_path in image_paths: # load the images image_tn = Image.open(image_path) image_tn = exif_orientation.correct_image_orientation(image_tn) image_tn.thumbnail(selectable_image.thumbnail_size, THUMBNAIL_METHOD) # create tuple and place into queue data = (image_path, image_tn) mt_queue.put(data)
def resize_files(self): def get_value(): size = self.size_var.get() # if size is not a valid integer, None is returned # could use a better warning message... return size def verify_value(v): return v and 0 < v < 5000 size = self.size_modifier_frame.get_size() # todo, edit box should verify this value, use lose focus callback if not verify_value(size): logging.error('Invalid value for size: %s' % str(size)) else: selected_image_paths = self.source_image_frame.get_selected_image_paths() logging.debug(selected_image_paths) for source_path in selected_image_paths: image_name = os.path.basename(source_path) image_name_parts = os.path.splitext(image_name) image_name = image_name_parts[0] + '_resized_' + str(size) + image_name_parts[1] destination_path = os.path.join(self.destination_directory, image_name) logging.debug(''.join([source_path, destination_path])) if os.path.exists(destination_path): logging.warning('SKIPPING: %s: FILE EXISTS' % destination_path) continue else: try: image = Image.open(source_path) image = exif_orientation.correct_image_orientation(image) image.thumbnail((size, size), Image.ANTIALIAS) image.save(destination_path) except Exception as e: logging.error('Error resizing image: %s' % source_path) logging.error(str(e)) if selected_image_paths: self.source_image_frame.unselect_all_images() self.destination_image_frame.load_all_images_from_directory(self.destination_directory)