Skip to content

Write

Source

Functions relating to writing image files of different formats.

WriteFunc

Bases: Protocol

Protocol for type hinting write functions.

__call__(file_path, img, *args, **kwargs)

Type hinted callables must match this function signature (not including self).

Parameters:

  • file_path (Path) –

    Path to file.

  • img (ndarray) –

    Image data to save.

  • *args

    Other positional arguments.

  • **kwargs

    Other keyword arguments.

get_write_func(data_type)

Get the write function for the data type.

Parameters:

  • data_type ((tiff, custom), default: "tiff" ) –

    Data type.

Returns:

write_tiff(file_path, img, *args, **kwargs)

Write tiff files.

Parameters:

  • file_path (Path) –

    Path to file.

  • img (ndarray) –

    Image data to save.

  • *args

    Positional arguments passed to tifffile.imwrite.

  • **kwargs

    Keyword arguments passed to tifffile.imwrite.

Raises:

  • ValueError

    When the file extension of file_path does not match the Unix shell-style pattern '.tif'.