Skip to content

daft.functions.image_width#

image_width #

image_width(image: Expression) -> Expression

Gets the width of an image in pixels.

Parameters:

Name Type Description Default
image Image Expression

image to retrieve the width from.

required

Returns:

Name Type Description
Expression UInt32 Expression

An Expression representing the width of the image.

Example

import daft from daft.functions import image_width

Create a dataframe with an image column#

df = ... # doctest: +SKIP df = df.with_column("width", image_width(df["images"])) # doctest: +SKIP

Source code in daft/functions/image.py
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
def image_width(image: Expression) -> Expression:
    """Gets the width of an image in pixels.

    Args:
        image (Image Expression): image to retrieve the width from.

    Returns:
        Expression (UInt32 Expression): An Expression representing the width of the image.

    Example:
        >>> import daft
        >>> from daft.functions import image_width
        >>> # Create a dataframe with an image column
        >>> df = ...  # doctest: +SKIP
        >>> df = df.with_column("width", image_width(df["images"]))  # doctest: +SKIP
    """
    return image_attribute(image, "width")