- PillowPlugin.write(ndimage: Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]], List[Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]]], *, mode: Optional[str] = None, format: Optional[str] = None, is_batch: Optional[bool] = None, **kwargs) Optional[bytes] #
Write an ndimage to the URI specified in path.
If the URI points to a file on the current host and the file does not yet exist it will be created. If the file exists already, it will be appended if possible; otherwise, it will be replaced.
If necessary, the image is broken down along the leading dimension to fit into individual frames of the chosen format. If the format doesn’t support multiple frames, and IOError is raised.
- imagendarray or list
The ndimage to write. If a list is given each element is expected to be an ndimage.
Specify the image’s color format. If None (default), the mode is inferred from the array’s shape and dtype. Possible modes can be found at: https://pillow.readthedocs.io/en/stable/handbook/concepts.html#modes
Optional format override. If omitted, the format to use is determined from the filename extension. If a file object was used instead of a filename, this parameter must always be used.
Explicitly tell the writer that
imageis a batch of images (True) or not (False). If None, the writer will guess this from the provided
image.shape. While the latter often works, it may cause problems for small images due to aliasing of spatial and color-channel axes.
Extra arguments to pass to pillow. If a writer doesn’t recognise an option, it is silently ignored. The available options are described in pillow’s image format documentation for each writer.
When writing batches of very narrow (2-4 pixels wide) gray images set the
modeexplicitly to avoid the batch being identified as a colored image.