  import sys
  import tkinter as tk
  from tkinter import filedialog, ttk
  from PIL import Image, ImageTk
  
  from lib.Serializer import JSONSerializer
  from .tooltip import Tooltip
 
</s> remove     def extract_tabs(self):
 </s> add     def extract_tabs(self, command="extract"): </s> remove         PreviewExtract(self, "preview", helptext, 5000)
 </s> add         PreviewExtract(self, "preview", helptext, 5000, command) </s> remove             logger.info("NB: Parallel processing disabled.You may get faster "
                        "extraction speeds by enabling it with the -mp switch")
 </s> add             logger.debug("Parallel processing disabled by cli.") </s> remove         # Get penultimate file so we don't accidentally
        # load a file that is being saved
        show_file = sorted(imagefiles, key=os.path.getctime)[-2]
        img = Image.open(show_file)
        img.thumbnail((768, 432))
        logger.trace("Displaying preview: '%s'", show_file)
        self.previewoutput = (img, ImageTk.PhotoImage(img))
 </s> add         logger.trace("Image Files: %s", len(imagefiles))
        num_images = (frame_dims[0] // thumbnail_size) * (frame_dims[1] // thumbnail_size)
        if num_images > len(imagefiles):
            logger.debug("Not enough images to generate display. (to display: %s, available "
                         "images: %s)", num_images, len(imagefiles))
            self.previewoutput = None
            return
        filenames, samples = self.get_preview_samples(imagefiles, num_images, thumbnail_size)
        show_image = self.place_previews(samples, frame_dims)
        logger.trace("Displaying preview: '%s'", filenames)
        self.previewoutput = (show_image, ImageTk.PhotoImage(show_image))

    @staticmethod
    def get_preview_samples(imagefiles, num_images, thumbnail_size):
        """ Return a subset of the imagefiles images
            Exclude final file so we don't accidentally load a file that is being saved """
        logger.trace("num_images: %s", num_images)
        samples = list()
        start_idx = len(imagefiles) - (num_images + 1)
        end_idx = len(imagefiles) - 1
        logger.trace("start_idx: %s, end_idx: %s", start_idx, end_idx)
        show_files = sorted(imagefiles, key=os.path.getctime)[start_idx: end_idx]
        for fname in show_files:
            img = Image.open(fname)
            img.thumbnail((thumbnail_size, thumbnail_size))
            if img.size[0] != img.size[1]:
                # Pad to square
                new_img = Image.new("RGB", (thumbnail_size, thumbnail_size))
                new_img.paste(img, ((thumbnail_size - img.size[0])//2,
                                    (thumbnail_size - img.size[1])//2))
                img = new_img
            samples.append(np.array(img))
        samples = np.array(samples)
        logger.trace("Samples shape: %s", samples.shape)
        return show_files, samples

    @staticmethod
    def place_previews(samples, frame_dims):
        """ Stack the preview images to fit display """
        num_images, thumbnail_size = samples.shape[:2]
        logger.trace("num_images: %s, thumbnail_size: %s", num_images, thumbnail_size)
        cols, rows = frame_dims[0] // thumbnail_size, frame_dims[1] // thumbnail_size
        logger.trace("cols: %s, rows: %s", cols, rows)
        display = np.vstack([np.hstack(samples[row * cols: (row + 1) * cols])
                             for row in range(rows)])
        logger.trace("display shape: %s", display.shape)
        return Image.fromarray(display) </s> remove         logger.trace("Loading preview image")
 </s> add         logger.trace("Loading preview image: (thumbnail_size: %s, frame_dims: %s)",
                     thumbnail_size, frame_dims)
import numpy as np

  import sys
  import tkinter as tk
  from tkinter import filedialog, ttk
import numpy as np

  from PIL import Image, ImageTk
  
  from lib.Serializer import JSONSerializer
  from .tooltip import Tooltip
keep keep add keep keep keep keep
 GUI: Show more previews for extract and convert 
lib/gui/utils.py