Hugh Perkins
Hugh Perkins

Reputation: 8622

Add images to jupyter notebooks viewable through github in a private repo

I found that images embedded in jupyter markups by a simple eg ![](img/myimage.png) didnt display in the github notebook viewer, when the repository is private.

I tried a bunch of hacking around.

Apparently there is functionality in 4.x.x to embed images as base64 metadata? But I couldnt see that in my own notebook.

Upvotes: 9

Views: 2036

Answers (1)

Hugh Perkins
Hugh Perkins

Reputation: 8622

Finally, what worked for me, very simply, create a code cell that looks like:

from IPython.display import Image, display
display(Image(filename='img/myimage.png', embed=True))

This did:

  • loaded the local image img/myimage.png, into the notebook
  • embedded it in the notebook (probably as base64), so that it could be viewed via the github notebook viewer, with no issues
  • didnt involve embedding 400 lines of base64 into the code section itself :-)

Upvotes: 10

Related Questions