def fmt_image(
    self: GTSelf,
    columns: SelectExpr = None,
    rows: int | list[int] | None = None,
    height: str | int | None = None,
    width: str | int | None = None,
    sep: str = " ",
    path: str | Path | None = None,
    file_pattern: str = "{}",
    encode: bool = True,
) -> GTSelf:
    """Format image paths to generate images in cells.

    To more easily insert graphics into body cells, we can use the `fmt_image()` method. This allows
    for one or more images to be placed in the targeted cells. The cells need to contain some
    reference to an image file, either: (1) local paths to the files; (2) complete http/https to the
    files; (3) the file names, where a common path can be provided via `path=`; or (4) a fragment of
    the file name, where the `file_pattern=` argument helps to compose the entire file name and
    `path=` provides the path information. This should be expressly used on columns that contain
    *only* references to image files (i.e., no image references as part of a larger block of text).
    Multiple images can be included per cell by separating image references by commas. The `sep=`
    argument allows for a common separator to be applied between images.

    Parameters
    ----------
    columns
        The columns to target. Can either be a single column name or a series of column names
        provided in a list.
    rows
        In conjunction with `columns=`, we can specify which of their rows should undergo
        formatting. The default is all rows, resulting in all rows in targeted columns being
        formatted. Alternatively, we can supply a list of row indices.
    height
        The height of the rendered images.
    width
        The width of the rendered images.
    sep
        In the output of images within a body cell, `sep=` provides the separator between each
        image.
    path
        An optional path to local image files or an HTTP/HTTPS URL.
        This is combined with the filenames to form the complete image paths.
    file_pattern
        The pattern to use for mapping input values in the body cells to the names of the graphics
        files. The string supplied should use `"{}"` in the pattern to map filename fragments to
        input strings.
    encode
        The option to always use Base64 encoding for image paths that are determined to be local. By
        default, this is `True`.

    Returns
    -------
    GT
        The GT object is returned. This is the same object that the method is called on so that we
        can facilitate method chaining.

    Examples
    --------
    Using a small portion of `metro` dataset, let's create a new table. We will only include a few
    columns and rows from that table. The `lines` column has comma-separated listings of numbers
    corresponding to lines served at each station. We have a directory of SVG graphics for all of
    these lines in the package (the path for the image directory can be accessed via
    `files("great_tables") / "data/metro_images"`, using the `importlib_resources` package). The
    filenames roughly corresponds to the data in the `lines` column. The `fmt_image()` method can
    be used with these inputs since the `path=` and `file_pattern=` arguments allow us to compose
    complete and valid file locations. What you get from this are sequences of images in the table
    cells, taken from the referenced graphics files on disk.

    ```{python}
    from great_tables import GT
    from great_tables.data import metro
    from importlib_resources import files

    img_paths = files("great_tables") / "data/metro_images"

    metro_mini = metro[["name", "lines", "passengers"]].head(5)

    (
        GT(metro_mini)
        .fmt_image(
            columns="lines",
            path=img_paths,
            file_pattern="metro_{}.svg"
        )
        .fmt_integer(columns="passengers")
    )
    ```
    """

    # TODO: most parameter options should allow a polars expression (or from_column) ----
    # can other fmt functions do this kind of thing?
    expr_cols = [height, width, sep, path, file_pattern, encode]

    if any(isinstance(x, PlExpr) for x in expr_cols):
        raise NotImplementedError(
            "fmt_image currently does not support polars expressions for arguments other than"
            " columns and rows"
        )

    if height is None and width is None:
        height = "2em"

    formatter = FmtImage(self._tbl_data, height, width, sep, path, file_pattern, encode)
    return fmt(
        self,
        fns=FormatFns(html=formatter.to_html, latex=formatter.to_latex, default=formatter.to_html),
        columns=columns,
        rows=rows,
    )
Format image paths to generate images in cells.

    To more easily insert graphics into body cells, we can use the `fmt_image()` method. This allows
    for one or more images to be placed in the targeted cells. The cells need to contain some
    reference to an image file, either: (1) local paths to the files; (2) complete http/https to the
    files; (3) the file names, where a common path can be provided via `path=`; or (4) a fragment of
    the file name, where the `file_pattern=` argument helps to compose the entire file name and
    `path=` provides the path information. This should be expressly used on columns that contain
    *only* references to image files (i.e., no image references as part of a larger block of text).
    Multiple images can be included per cell by separating image references by commas. The `sep=`
    argument allows for a common separator to be applied between images.

    Parameters
    ----------
    columns
        The columns to target. Can either be a single column name or a series of column names
        provided in a list.
    rows
        In conjunction with `columns=`, we can specify which of their rows should undergo
        formatting. The default is all rows, resulting in all rows in targeted columns being
        formatted. Alternatively, we can supply a list of row indices.
    height
        The height of the rendered images.
    width
        The width of the rendered images.
    sep
        In the output of images within a body cell, `sep=` provides the separator between each
        image.
    path
        An optional path to local image files or an HTTP/HTTPS URL.
        This is combined with the filenames to form the complete image paths.
    file_pattern
        The pattern to use for mapping input values in the body cells to the names of the graphics
        files. The string supplied should use `"{}"` in the pattern to map filename fragments to
        input strings.
    encode
        The option to always use Base64 encoding for image paths that are determined to be local. By
        default, this is `True`.

    Returns
    -------
    GT
        The GT object is returned. This is the same object that the method is called on so that we
        can facilitate method chaining.

    Examples
    --------
    Using a small portion of `metro` dataset, let's create a new table. We will only include a few
    columns and rows from that table. The `lines` column has comma-separated listings of numbers
    corresponding to lines served at each station. We have a directory of SVG graphics for all of
    these lines in the package (the path for the image directory can be accessed via
    `files("great_tables") / "data/metro_images"`, using the `importlib_resources` package). The
    filenames roughly corresponds to the data in the `lines` column. The `fmt_image()` method can
    be used with these inputs since the `path=` and `file_pattern=` arguments allow us to compose
    complete and valid file locations. What you get from this are sequences of images in the table
    cells, taken from the referenced graphics files on disk.

    ```{python}
    from great_tables import GT
    from great_tables.data import metro
    from importlib_resources import files

    img_paths = files("great_tables") / "data/metro_images"

    metro_mini = metro[["name", "lines", "passengers"]].head(5)

    (
        GT(metro_mini)
        .fmt_image(
            columns="lines",
            path=img_paths,
            file_pattern="metro_{}.svg"
        )
        .fmt_integer(columns="passengers")
    )
    ```
    
great_tables/_formats.py