5.1. AbstractImageIOModule

5.1.1. Detailed Description

Abstract image IO class that provides overridable methods to determine custom image input and output operations. Every overridable method must be implemented. The methods should not call each other.

class mocha.mediaio.AbstractImageIOModule
class mocha.mediaio.AbstractImageIOModule(format_name, extensions, save_image_formats, save_image_types[, is_clip_loader=false])
Parameters
  • format_name (str) – Short description of custom format, e.g. “Maya Image Format”.

  • extensions (list of strings) – List of supported extensions, e.g. [‘.iff’].

  • save_image_formats (list of PixelFormat) – List of supported PixelFormat to persist.

  • save_image_types (list of ChannelType) – List of supported ChannelType to persist.

  • is_clip_loader (bool) – True if the loader returns multiple frames from a single file (such as with .MOV or .AVI).

Creates and registers custom image IO module. Create its instance in custom Python bootstrapping code to obtain appropriate image format in mocha backend.

AbstractImageIOModule.accepts_ext(extension)
Return type

bool

Parameters

ext_no_dot – File name suffix (extension) of the image file, with no leading dot.

Implements checking whether given file type is acceptable by the module.

AbstractImageIOModule.accepts_file(file_name)
Return type

bool

Parameters

file_name (str) – Absolute path to an image file.

Implements checking whether image file is acceptable by the module. Being called upon project opening.

AbstractImageIOModule.channel_type(file_name)
Return type

ChannelType

Parameters

file_name (str) – Absolute path to an image file.

Implements channel type getting for given file.

Parameters

file_name – Absolute path to an image file.

Implements channel type getting for given file.

AbstractImageIOModule.get_fps(path)
Return type

float

Parameters

path (str) – Absolute path to the clip file.

Implements determining the frame rate of a source clip.

AbstractImageIOModule.get_frame_count(path)
Return type

float

Parameters

path (str) – Absolute path to the clip file.

Implements determining the number of frames in the given clip.

AbstractImageIOModule.get_gamma(file_name)
Return type

OptionalFloat

Parameters

file_name (str) – Absolute path to an image file.

Implements gamma value getting. Return None if the module does not support this.

AbstractImageIOModule.get_interlace_mode(file_name)
Return type

InterlaceMode or None

Parameters

file_name (str) – Absolute path to an image file.

Implements interlace mode getting. Return None if the module does not support this.

AbstractImageIOModule.get_metadata(path, frame_number, stream_name)
Return type

Dictionary with keys of type QString and values of type QVariant.

Parameters
  • path (str) – Absolute path to the clip file.

  • frame_number (int) – Frame number to load.

  • stream_name (str) – Name of the stream to load.

Return a dictionary containing additional metadata for the given frame and stream, if there is any. The default implementation is to return an empty dictionary.

AbstractImageIOModule.get_stream_names(path)
Return type

list of QString

Parameters

path (str) – Absolute path to the clip file.

Return a list of available stream names for this clip. These stream names will be passed back as a parameter to load_image to load the respective image from a particular stream. If the clip does not contain multiple streams, an empty list can be returned as per the default implementation.

AbstractImageIOModule.image_size(file_name)
Return type

QSize

Parameters

file_name (str) – Absolute path to an image file.

Implements image size getting.

AbstractImageIOModule.load_image(image, path, frame_number, stream_name)
Parameters

image (ImageData) –

Empty image instance to fill in. :param path: Absolute path to an image file. :param frame_number: Number of the frame to load (only relevant for multi-frame clips) :param stream_name: Name of the stream name to load (only relevant for multi-stream files like OpenEXR)

Implements image loading. Set pixels property for given image instance as appropriate python array object (see docs of built-in python array module).

Important: loaded images should be vertically flipped.

AbstractImageIOModule.pixel_format(file_name)
Return type

PixelFormat

Parameters

file_name (str) – Absolute path to an image file.

Implements checking whether given file extension is acceptable by the module.

AbstractImageIOModule.save_image(image, path)
Parameters
  • image (ImageData) – Complete image instance.

  • path (str) – Absolute path to an image file to save.

Implements image saving.

Important: mocha presents vertically flipped images only.

AbstractImageIOModule.supports_image(file_name, format, pixels_type)
Return type

bool

Parameters
  • file_name (str) – Absolute path to an image file.

  • format (PixelFormat) – Image format.

  • pixels_type (ChannelType) – Pixels type.

Implements checking whether the module supports image persisting with given path, image format and pixels type.