Writer
- class plugins.convert.writer.pillow.Writer(output_folder: str, **kwargs)
Bases:
OutputImages output writer using Pillow
- Parameters:
output_folder (str) – The full path to the output folder where the converted media should be saved
config_file (str, optional) – The full path to a custom configuration ini file. If
Noneis passed then the file is loaded from the default location. Default:None.
Attributes Summary
Whether the writer outputs a stream or a series images.
Pillow can output alpha channel.
Methods Summary
cache_frame(filename, image)Add the incoming converted frame to the cache ready for writing out.
close()Does nothing as Pillow writer does not need a close method
get_output_filename(filename, extension[, ...])Obtain the full path for the output file, including the correct extension, for the given input filename.
pre_encode(image, **kwargs)Pre_encode the image in lib/convert.py threads as it is a LOT quicker
write(filename, image)Write out the pre-encoded image to disk.
Attributes Documentation
- is_stream
Whether the writer outputs a stream or a series images.
Writers that write to a stream have a frame_order parameter to dictate the order in which frames should be written out (eg. gif/ffmpeg)
- output_alpha
Pillow can output alpha channel. Returns
True- Type:
bool
Methods Documentation
- cache_frame(filename: str, image: ndarray) None
Add the incoming converted frame to the cache ready for writing out.
Used for ffmpeg and gif writers to ensure that the frames are written out in the correct order.
- Parameters:
filename (str) – The filename of the incoming frame, where the frame index can be extracted from
image (ndarray) – The converted frame corresponding to the given filename
- Return type:
None
- close() None
Does nothing as Pillow writer does not need a close method
- Return type:
None
- get_output_filename(filename: str, extension: str, separate_mask: bool = False) list[str]
Obtain the full path for the output file, including the correct extension, for the given input filename.
- Parameters:
filename (str) – The input frame filename to generate the output file name for
extension (str) – The extension to use for the output file
separate_mask (bool) –
Trueif the mask should be saved out to a sub-folder otherwiseFalse
- Returns:
The full path for the output converted frame to be saved to in position 1. The full path
for the mask to be output to in position 2 (if requested)
- Return type:
list[str]
- pre_encode(image: ndarray, **kwargs) list[BytesIO]
Pre_encode the image in lib/convert.py threads as it is a LOT quicker
- Parameters:
image (
numpy.ndarray) – A 3 or 4 channel BGR swapped frame- Returns:
List of
BytesIOobjects ready for writing. The list will be of length 1 with image bytes object as the only member unless separate mask has been requested, in which case it will be length 2 with the image in position 0 and mask in position 1- Return type:
list
- write(filename: str, image: list[BytesIO]) None
Write out the pre-encoded image to disk. If separate mask has been selected, write out the encoded mask to a sub-folder in the output directory.
- Parameters:
filename (str) – The full path to write out the image to.
image (list) – List of
BytesIOobjects of length 1 (containing just the image to write out) or length 2 (containing the image and mask to write out)
- Return type:
None
- close() None
Does nothing as Pillow writer does not need a close method
- Return type:
None
- property output_alpha: bool
Pillow can output alpha channel. Returns
True- Type:
bool
- pre_encode(image: ndarray, **kwargs) list[BytesIO]
Pre_encode the image in lib/convert.py threads as it is a LOT quicker
- Parameters:
image (
numpy.ndarray) – A 3 or 4 channel BGR swapped frame- Returns:
List of
BytesIOobjects ready for writing. The list will be of length 1 with image bytes object as the only member unless separate mask has been requested, in which case it will be length 2 with the image in position 0 and mask in position 1- Return type:
list
- write(filename: str, image: list[BytesIO]) None
Write out the pre-encoded image to disk. If separate mask has been selected, write out the encoded mask to a sub-folder in the output directory.
- Parameters:
filename (str) – The full path to write out the image to.
image (list) – List of
BytesIOobjects of length 1 (containing just the image to write out) or length 2 (containing the image and mask to write out)
- Return type:
None