Writing image stack with HDF5

The HDF5 format can be used for almost anything, including image stacks. To signal graphical interactive HDF5 viewers that a dataset is an image stack, add HDF5 image metadata, as in this Python h5py example:

import numpy as np
import h5py

# images is a numpy ndarray N x X x Y images

with h5py.File("image.h5", "w") as f:
    h = f.create_dataset("/images", data=images)
    h.attrs["CLASS"] = np.string_("IMAGE")
    h.attrs["IMAGE_VERSION"] = np.string_("1.2")
    h.attrs["IMAGE_SUBCLASS"] = np.string_("IMAGE_GRAYSCALE")
    h.attrs["DISPLAY_ORIGIN"] = np.string_("LL")
    h.attrs["IMAGE_WHITE_IS_ZERO"] = np.uint8(0)

HDFview will show an optional video player for this dataset due to the image metadata added.