Lib

A collection of various utilities.

class lablib.lib.ImageInfo(path=<factory>)[source]

A dataclass for reading image metadata.

Note

All attributes are optional and will be set from calling iinfo and ffprobe in ImageInfo.update() if found. Defaults are set if not found and set by user. See the next example for defaults.

Example with Defaults

image = ImageInfo(
    path=Path("path/to/image.exr"),
    width = 1920
    height = 1080
    channels = 3
    fps = 24.0
    par = 1.0
    timecode = "00:00:00:00"
    origin_x = 0
    origin_y = 0
    display_width = 1920
    display_height = 1080
)
path

Path to the image file.

Type:

Path

width

Image width.

Type:

Optional[int]

height

Image height.

Type:

Optional[int]

origin_x

Origin x position.

Type:

Optional[int]

origin_y

Origin y position.

Type:

Optional[int]

display_width

Display width.

Type:

Optional[int]

display_height

Display height.

Type:

Optional[int]

par

Pixel aspect ratio.

Type:

Optional[float]

channels

Number of channels.

Type:

Optional[int]

fps

Frames per second.

Type:

Optional[float]

timecode

Timecode.

Type:

Optional[str]

property extension

The file extension.

Type:

str

property filename

The image file name including extension.

Type:

str

property filepath

The file path as posix string.

Type:

str

property frame_number

Retrieved from the filename by using regex lookup.

Note

The regex could use a little love to be more robust. Filename should be something like filename.0001.exr.

Type:

int

property name

The file name with extension.

Note

Used in SequenceInfo but could become obsolete in favor for filename.

Type:

str

property rational_time

Retrieved from ImageInfo.timecode using otio library.

Type:

opentime.RationalTime

update(force_ffprobe=False)[source]

Updates metadata by calling iinfo and ffprobe.

Attention

During testing it was found that ffprobe reported different framerates on different systems. Therefore we added the force_ffprobe=False flag to silently disable ffprobe.

Parameters:

force_ffprobe (Optional[bool]) – whether to override attributes with ffprobe output if found.

class lablib.lib.SequenceInfo(path=<factory>, imageinfos=<factory>)[source]

Class for handling image sequences by using instances of ImageInfo.

Hint

If you want to scan a directory for image sequences, you can use the scan classmethod.

path Any[Path, str]

Path to the image sequence directory.

imageinfos List[ImageInfo]

List of all files as ImageInfo to be used.

property display_height

the sequence’s display_height based on the first frame found.

Type:

int

property display_width

the sequence’s display_width based on the first frame found.

Type:

int

property end_frame

the highest frame number in the sequence.

Type:

int

property format_string

A sequence representation used for ffmpeg arguments formatting. # noqa

Error

That’s a duplicate so let’s run tests and remove it.

Type:

str

property frames

List of all available frame numbers in the sequence.

Type:

List[int]

property frames_missing

Property for checking if any frames are missing in the sequence. # noqa

Note

Could be extended to also return which frames are missing.

Type:

bool

property hash_string

A sequence representation used for oiiotool arguments formatting.

Type:

str

property height

the sequence’s height based on the first frame found.

Type:

int

property padding

The sequence’s frame padding.

Type:

int

classmethod scan(directory)[source]

Scan a directory for a list of images.

Attention

Currently only supports EXR files. Needs to be extended and tested for other formats.

Parameters:

directory (Any[str, Path]) – Path to the directory to be scanned.

Returns:

List of all found sequences.

Return type:

List[SequenceInfo]

property start_frame

the lowest frame number in the sequence.

Type:

int

property width

the sequence’s width based on the first frame found.

Type:

int

lablib.lib.get_vendored_env()[source]

Get a prepared copy of the current environment.

Checks for the presence of $OCIO, $LABLIB_OIIO and $LABLIB_FFMPEG and adds them to $PATH. If these environment variables are not set, it assumes vendored files to be present in ./vendor.

Hint

Run .\start.ps1 get-dependencies to download the vendored files.

Returns:

Dict[str, Any]