Skip to content

daft.functions.image_attribute#

image_attribute #

image_attribute(image: Expression, name: Literal['width', 'height', 'channel', 'mode'] | ImageProperty) -> Expression

Get a property of the image, such as 'width', 'height', 'channel', or 'mode'.

Parameters:

Name Type Description Default
image Image Expression

to retrieve the property from.

required
name Literal['width', 'height', 'channel', 'mode'] | ImageProperty

The name of the property to retrieve.

required

Returns:

Name Type Description
Expression Expression

An Expression representing the requested property.

Source code in daft/functions/image.py
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
def image_attribute(
    image: Expression, name: Literal["width", "height", "channel", "mode"] | ImageProperty
) -> Expression:
    """Get a property of the image, such as 'width', 'height', 'channel', or 'mode'.

    Args:
        image (Image Expression): to retrieve the property from.
        name: The name of the property to retrieve.

    Returns:
        Expression: An Expression representing the requested property.
    """
    if isinstance(name, str):
        name = ImageProperty.from_property_string(name)
    return Expression._call_builtin_scalar_fn("image_attribute", image, name)