Skip to content

Instantly share code, notes, and snippets.

Last active February 5, 2023 21:08
What would you like to do?
Jupyter Tidbit: Display an image gallery


JupyterLab and Jupyter Notebook can display HTML-embedded images in notebook documents. You can use the IPython.display.HTML class to structure these images into a basic image gallery.



The notebook below defines a gallery() function that accepts a list of image URLs, local image file paths, or bytes in memory. The function displays the images from left-to-right, top-to-bottom in the notebook. An optional max_height parameter scales all images to the same height to create more regular looking rows.

The notebook includes two demos of the function output.

Why is this useful?

You may find a gallery view useful when you need to visually scan a large set of images. The horizontal layout helps reduce notebook scrolling. The fixed height option lets you pack more images on the screen at once and spot coarse differences.

Copy link

Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment