          """ 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("num_images: %s, thumbnail_size: %s", num_images, thumbnail_size)
 </s> add         if self.previewcache["placeholder"] is None:
            self.create_placeholder(thumbnail_size)

        logger.debug("num_images: %s, thumbnail_size: %s", num_images, thumbnail_size) </s> remove         logger.trace("display shape: %s", display.shape)
 </s> add         logger.debug("display shape: %s", display.shape) </s> remove     @staticmethod
    def place_previews(samples, frame_dims):
 </s> add     def place_previews(self, frame_dims):
        logger.debug("cols: %s, rows: %s", cols, rows)
        remainder = (cols * rows) % num_images
        if remainder != 0:
            logger.debug("Padding final row. Remainder: %s", remainder)
            placeholder = np.concatenate([np.expand_dims(self.previewcache["placeholder"],
                                                         0)] * remainder)
            samples = np.concatenate((samples, placeholder))
          """ 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.debug("cols: %s, rows: %s", cols, rows)
        remainder = (cols * rows) % num_images
        if remainder != 0:
            logger.debug("Padding final row. Remainder: %s", remainder)
            placeholder = np.concatenate([np.expand_dims(self.previewcache["placeholder"],
                                                         0)] * remainder)
            samples = np.concatenate((samples, placeholder))
          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)
  
keep keep keep keep replace keep keep keep keep keep
 GUI: Preview for convert

Display preview when outputting to a stream container (e.g. video, gif) 
lib/gui/utils.py