I would like to include image in a jupyter notebook.
If I did the following, it works :
from IPython.display import Image Image("img/picture.png")
But I would like to include the images in a markdown cell and the following code gives a 404 error :
![title]("img/picture.png")
I also tried
![texte]("http://localhost:8888/img/picture.png")
But I still get the same error :
404 GET /notebooks/%22/home/user/folder/img/picture.png%22 (127.0.0.1) 2.74ms referer=http://localhost:8888/notebooks/notebook.ipynb
Right-click on a file or directory and select “Copy Shareable Link” to copy a URL that can be used to open JupyterLab with that file or directory open. Right-click on a file or directory and select “Copy Path” to copy the filesystem relative path.
To read the image using OpenCV I have defined load_images_from_folder function which takes a path where images are stored as an input parameter , In the next step cv2. imread function read all files in a folder and append them to images =[] list then return images list.
You mustn't use quotation marks around the name of the image files in markdown!
If you carefully read your error message, you will see the two %22
parts in the link. That is the html encoded quotation mark.
You have to change the line
![title]("img/picture.png")
to
![title](img/picture.png)
UPDATE
It is assumed, that you have the following file structure and that you run the jupyter notebook
command in the directory where the file example.ipynb
(<-- contains the markdown for the image) is stored:
/ +-- example.ipynb +-- img +-- picture.png
There are several ways to post an image in Jupyter notebooks:
from IPython.display import Image from IPython.core.display import HTML Image(url= "http://my_site.com/my_picture.jpg")
You retain the ability to use HTML tags to resize, etc...
Image(url= "http://my_site.com/my_picture.jpg", width=100, height=100)
You can also display images stored locally, either via relative or absolute path.
PATH = "/Users/reblochonMasque/Documents/Drawings/" Image(filename = PATH + "My_picture.jpg", width=100, height=100)
if the image it wider than the display settings: thanks
use unconfined=True
to disable max-width confinement of the image
from IPython.core.display import Image, display display(Image(url='https://i.ytimg.com/vi/j22DmsZEv30/maxresdefault.jpg', width=1900, unconfined=True))
![title](../image 1.png)
, and not worry about the white space).for a web image:
![Image of Yaktocat](https://octodex.github.com/images/yaktocat.png)
as shown by @cristianmtr Paying attention not to use either these quotes ""
or those ''
around the url.
or a local one:
![title](img/picture.png)
demonstrated by @Sebastian
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With