1

In Jupyter Notebook I can use the following:

import ipywidgets as widgets

file = open("./image.png", "rb")
image = file.read()
widgets.Image(
    value=image,
    format='png',
    width=700,
    height=100,
)

This doesn't work in Jupyter Lab though, what is the Jupyter Lab version of the above?

baxx
  • 3,956
  • 6
  • 37
  • 75
  • The simplest way is this (without writing code is): https://stackoverflow.com/questions/10628262/inserting-image-into-ipython-notebook-markdown/55623116#55623116 – Rich Lysakowski PhD Apr 22 '22 at 08:36
  • This question has already been answered at [Inserting image into IPython notebook markdown](https://stackoverflow.com/questions/10628262/inserting-image-into-ipython-notebook-markdown/55623116#55623116) – Rich Lysakowski PhD Apr 22 '22 at 08:37
  • @RichLysakowskiPhD "drag and drop" is not an answer to the question asked in this post, it's referencing a specific code snippet which worked in notebook. – baxx Apr 23 '22 at 21:59

1 Answers1

2

A very simple solution would be, via Markdown :-)

you can do it directly in a markdown cell:

![title](./image.png)

or via a python cell:

from IPython.display import HTML, display, Markdown, Latex
display(Markdown("![title](./image.png)")

or via a markdown cell:

<img src="./image.png" style="height: 300px;"/>

Or via a python cell:

display(Markdown('<img src="image.png" style="height: 300px;"/>'))
Dieter
  • 2,499
  • 1
  • 23
  • 41