PreviewExtract

class lib.gui.utils.image.PreviewExtract(cache_path: str)

Bases: object

Handles the loading of preview images for extract and convert

Parameters:

cache_path (str) – Full path to the cache folder that contains the preview images

Attributes Summary

image

PIL.ImageTk.PhotoImage The preview image for displaying in a tkinter canvas

Methods Summary

delete_previews()

Remove any image preview files

load_latest_preview(thumbnail_size, frame_dims)

Load the latest preview image for extract and convert.

save(filename)

Save the currently displaying preview image to the given location

set_faceswap_output_path(location[, batch_mode])

Set the path that will contain the output from an Extract or Convert task.

Attributes Documentation

image

PIL.ImageTk.PhotoImage The preview image for displaying in a tkinter canvas

Methods Documentation

delete_previews() None

Remove any image preview files

Return type:

None

load_latest_preview(thumbnail_size: int, frame_dims: tuple[int, int]) bool

Load the latest preview image for extract and convert.

Retrieves the latest preview images from the faceswap output folder, resizes to thumbnails and lays out for display. Places the images into preview_image for loading into the display panel.

Parameters:
  • thumbnail_size (int) – The size of each thumbnail that should be created

  • frame_dims (tuple) – The (width (int), height (int)) of the display panel that will display the preview

Returns:

True if a preview was successfully loaded otherwise False

Return type:

bool

save(filename: str) None

Save the currently displaying preview image to the given location

Parameters:

filename (str) – The full path to the filename to save the preview image to

Return type:

None

set_faceswap_output_path(location: str, batch_mode: bool = False) None

Set the path that will contain the output from an Extract or Convert task.

Required so that the GUI can fetch output images to display for return in preview_image.

Parameters:
  • location (str) – The output location that has been specified for an Extract or Convert task

  • batch_mode (bool) – True if extracting in batch mode otherwise False

Return type:

None

delete_previews() None

Remove any image preview files

Return type:

None

property image: PhotoImage

PIL.ImageTk.PhotoImage The preview image for displaying in a tkinter canvas

load_latest_preview(thumbnail_size: int, frame_dims: tuple[int, int]) bool

Load the latest preview image for extract and convert.

Retrieves the latest preview images from the faceswap output folder, resizes to thumbnails and lays out for display. Places the images into preview_image for loading into the display panel.

Parameters:
  • thumbnail_size (int) – The size of each thumbnail that should be created

  • frame_dims (tuple) – The (width (int), height (int)) of the display panel that will display the preview

Returns:

True if a preview was successfully loaded otherwise False

Return type:

bool

save(filename: str) None

Save the currently displaying preview image to the given location

Parameters:

filename (str) – The full path to the filename to save the preview image to

Return type:

None

set_faceswap_output_path(location: str, batch_mode: bool = False) None

Set the path that will contain the output from an Extract or Convert task.

Required so that the GUI can fetch output images to display for return in preview_image.

Parameters:
  • location (str) – The output location that has been specified for an Extract or Convert task

  • batch_mode (bool) – True if extracting in batch mode otherwise False

Return type:

None