          if not imagefiles or len(imagefiles) == 1:
              logger.debug("No preview to display")
              self.previewoutput = None
              return
          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))
 
</s> remove             self.previewoutput = None
 </s> add #            self.previewoutput = None </s> remove         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)
 </s> add         self.load_images_to_cache(imagefiles, frame_dims, thumbnail_size)
        if imagefiles == [gui_preview]:
            # Delete the preview image so that the main scripts know to output another
            logger.debug("Deleting preview image")
            os.remove(imagefiles[0])
        show_image = self.place_previews(frame_dims)
        logger.debug("Displaying preview: '%s'", self.previewcache["filenames"]) </s> remove         if not imagefiles or len(imagefiles) == 1:
 </s> add         gui_preview = os.path.join(self.pathoutput, ".gui_preview.jpg")
        if not imagefiles or (len(imagefiles) == 1 and gui_preview not in imagefiles): </s> remove         logger.trace("Loading preview image: (thumbnail_size: %s, frame_dims: %s)",
 </s> add         logger.debug("Loading preview image: (thumbnail_size: %s, frame_dims: %s)", </s> remove         logger.trace("cols: %s, rows: %s", cols, rows)
 </s> add         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))
        # Filter to just the gui_preview if it exists in folder output
        imagefiles = [gui_preview] if gui_preview in imagefiles else imagefiles
        logger.debug("Image Files: %s", len(imagefiles))

        imagefiles = self.get_newest_filenames(imagefiles)
        if not imagefiles:
          if not imagefiles or len(imagefiles) == 1:
              logger.debug("No preview to display")
              self.previewoutput = None
              return
        # Filter to just the gui_preview if it exists in folder output
        imagefiles = [gui_preview] if gui_preview in imagefiles else imagefiles
        logger.debug("Image Files: %s", len(imagefiles))

        imagefiles = self.get_newest_filenames(imagefiles)
        if not imagefiles:
        # Filter to just the gui_preview if it exists in folder output
        imagefiles = [gui_preview] if gui_preview in imagefiles else imagefiles
        logger.debug("Image Files: %s", len(imagefiles))

        imagefiles = self.get_newest_filenames(imagefiles)
        if not imagefiles:
        # Filter to just the gui_preview if it exists in folder output
        imagefiles = [gui_preview] if gui_preview in imagefiles else imagefiles
        logger.debug("Image Files: %s", len(imagefiles))

        imagefiles = self.get_newest_filenames(imagefiles)
        if not imagefiles:
        # Filter to just the gui_preview if it exists in folder output
        imagefiles = [gui_preview] if gui_preview in imagefiles else imagefiles
        logger.debug("Image Files: %s", len(imagefiles))

        imagefiles = self.get_newest_filenames(imagefiles)
        if not imagefiles:
        # Filter to just the gui_preview if it exists in folder output
        imagefiles = [gui_preview] if gui_preview in imagefiles else imagefiles
        logger.debug("Image Files: %s", len(imagefiles))

        imagefiles = self.get_newest_filenames(imagefiles)
        if not imagefiles:
        # Filter to just the gui_preview if it exists in folder output
        imagefiles = [gui_preview] if gui_preview in imagefiles else imagefiles
        logger.debug("Image Files: %s", len(imagefiles))

        imagefiles = self.get_newest_filenames(imagefiles)
        if not imagefiles:
              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))
keep keep keep keep replace replace replace replace replace 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