Display images in Jupyter web UI, that is JupyterLab and Jupyter Notebook.
Encodes the image directly into HTML (base64) without going through matplotlib.
The compression format is customizable. A single function call can show multiple images in a grid.
show(img_1, img_2)
will draw each image on a separate rowshow([img_1, img_2])
will draw both images in one rowshow([img_1, img_2], [img_3, img_4])
will draw two rows of two images
Specifying the format:
show(..., fmt='webp')
: image format, usually png jpeg webpshow.set_default_image_format('webp')
- The default is
png
, please usewebp
orjpeg
to reduce notebook file size
Whether to try converting unusual shapes and datatypes to the needed RGB:
show(..., adapt=True or False)
Convenience functions imread
, imwrite
are also provided (based on PIL).
Try the demo notebook.
pip install show-image
or
- Include the file
show_image.py
in your project - Ensure libraries are installed:
Pillow numpy matplotlib ipython