Skip to content

color

Classes:

InvalidColorspacePathError

InvalidColorspacePathError(
    func: FuncExceptT, message: SupportsString | None = None, **kwargs: Any
)

Bases: CustomValueError

Raised when there is no path between two colorspaces.

Methods:

  • check

    Check if there's a valid colorspace path for the given clip.

Source code
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def __init__(
    self, func: FuncExceptT, message: SupportsString | None = None,
    **kwargs: Any
) -> None:
    def_msg = 'Unable to convert between colorspaces! '
    def_msg += 'Please provide more colorspace information (e.g., matrix, transfer, primaries).'

    if isinstance(message, vs.Error):
        error_msg = str(message)
        if 'Resize error:' in error_msg:
            kwargs['reason'] = error_msg[error_msg.find('(') + 1:error_msg.rfind(')')]
            message = def_msg

    super().__init__(message or def_msg, func, **kwargs)

check staticmethod

check(func: FuncExceptT, to_check: VideoNode) -> None

Check if there's a valid colorspace path for the given clip.

Parameters:

  • func

    (FuncExceptT) –

    Function returned for custom error handling. This should only be set by VS package developers.

  • to_check

    (VideoNode) –

    Value to check. Must be a VideoNode.

Raises:

  • InvalidColorspacePathError

    If there's no valid colorspace path.

Source code
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@staticmethod
def check(func: FuncExceptT, to_check: vs.VideoNode) -> None:
    """
    Check if there's a valid colorspace path for the given clip.

    :param func:        Function returned for custom error handling.
                        This should only be set by VS package developers.
    :param to_check:    Value to check. Must be a VideoNode.

    :raises InvalidColorspacePathError: If there's no valid colorspace path.
    """

    try:
        to_check.get_frame(0).close()
    except vs.Error as e:
        if 'no path between colorspaces' in str(e):
            raise InvalidColorspacePathError(func, e)
        raise

InvalidMatrixError

InvalidMatrixError(
    func: FuncExceptT,
    matrix: int = 2,
    message: SupportsString = "You can't set a matrix of {matrix}!",
    **kwargs: Any
)

Bases: CustomValueError

Raised when an invalid matrix is passed.

Source code
89
90
91
92
93
def __init__(
    self, func: FuncExceptT, matrix: int = 2, message: SupportsString = 'You can\'t set a matrix of {matrix}!',
    **kwargs: Any
) -> None:
    super().__init__(message, func, matrix=matrix, **kwargs)

InvalidPrimariesError

InvalidPrimariesError(
    func: FuncExceptT,
    primaries: int = 2,
    message: SupportsString = "You can't set primaries of {primaries}!",
    **kwargs: Any
)

Bases: CustomValueError

Raised when an invalid matrix is passed.

Source code
139
140
141
142
143
def __init__(
    self, func: FuncExceptT, primaries: int = 2,
    message: SupportsString = 'You can\'t set primaries of {primaries}!', **kwargs: Any
) -> None:
    super().__init__(message, func, primaries=primaries, **kwargs)

InvalidTransferError

InvalidTransferError(
    func: FuncExceptT,
    transfer: int = 2,
    message: SupportsString = "You can't set a transfer of {transfer}!",
    **kwargs: Any
)

Bases: CustomValueError

Raised when an invalid matrix is passed.

Source code
114
115
116
117
118
def __init__(
    self, func: FuncExceptT, transfer: int = 2,
    message: SupportsString = 'You can\'t set a transfer of {transfer}!', **kwargs: Any
) -> None:
    super().__init__(message, func, transfer=transfer, **kwargs)

ReservedMatrixError

Bases: CustomPermissionError

Raised when a reserved matrix is requested.

ReservedPrimariesError

Bases: CustomPermissionError

Raised when reserved primaries are requested.

ReservedTransferError

Bases: CustomPermissionError

Raised when a reserved transfer is requested.

UndefinedMatrixError

Bases: CustomValueError

Raised when an undefined matrix is passed.

UndefinedPrimariesError

Bases: CustomValueError

Raised when an undefined primaries value is passed.

UndefinedTransferError

Bases: CustomValueError

Raised when an undefined transfer is passed.

UnsupportedColorRangeError

Bases: CustomValueError

Raised when a unsupported color range value is passed.

UnsupportedMatrixError

Bases: CustomValueError

Raised when an unsupported matrix is passed.

UnsupportedPrimariesError

Bases: CustomValueError

Raised when a unsupported primaries value is passed.

UnsupportedTransferError

Bases: CustomValueError

Raised when an unsupported transfer is passed.