Skip to content

daft.functions.image_mode#

image_mode #

image_mode(image: Expression) -> Expression

Gets the mode of an image.

Parameters:

Name Type Description Default
image Image Expression

image to retrieve the mode from.

required

Returns:

Name Type Description
Expression UInt32 Expression

An Expression representing the mode of the image.

Example

import daft from daft.functions import image_mode

Create a dataframe with an image column#

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

Source code in daft/functions/image.py
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
def image_mode(image: Expression) -> Expression:
    """Gets the mode of an image.

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

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

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