porespy.io.zip_to_stack#

porespy.io.zip_to_stack(f, *, max_bytes=None)#

Read a ZIP of 2D grayscale image slices into one 3D array.

Parameters:
  • f (str, path object or file-like object) – ZIP archive containing the slices, either at its root or in one folder. A file-like object must be seekable and opened in binary mode.

  • max_bytes (int, optional) – Maximum size in bytes of the returned array, as in folder_to_stack. By default, no limit is imposed.

Returns:

im – Array with shape (rows, columns, number_of_slices) and the slices’ original dtype and values.

Return type:

ndarray

Raises:

ValueError – For the slice and size validation failures listed in folder_to_stack, or if image members have unsafe paths, are symbolic links, have duplicate names, or occur in more than one folder.

Notes

Slice formats, natural filename ordering and validation are the same as in folder_to_stack. Hidden files, __MACOSX metadata and files with unrecognized extensions are ignored. Images must all share one parent folder; separate series are never combined automatically.

Members are read directly from the ZIP without extraction. No directory is created, overwritten or deleted on disk, including on failure.

See also

folder_to_stack