cancel
Showing results for 
Search instead for 
Did you mean: 
Machine Learning
Dive into the world of machine learning on the Databricks platform. Explore discussions on algorithms, model training, deployment, and more. Connect with ML enthusiasts and experts.
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I embed image to my notebook?

Anonymous
Not applicable
 
1 ACCEPTED SOLUTION

Accepted Solutions

sean_owen
Databricks Employee
Databricks Employee

If the image is a result of, for example, a plotting library's output, it should just render as-is.

If it's not, then one simple approach is to write a markdown (%md) cell and include a link to the image:

![](url of the image)

Of course this requires that the image be available somewhere to link to. You can write images to /FileStore on DBFS, and they become available at a URL in your workspace starting with /files. Note that this isn't exactly secure though, as anyone in the workspace could potentially see that file. In some cases that's fine.

For small images, you could encode the bytes of the PNG (for example) image in base64 and then construct a a "data:" URI with that image data. That becomes a self-contained URI you can render in HTML in a markdown cell like any other image. That's only a good idea for pretty small images though.

View solution in original post

1 REPLY 1

sean_owen
Databricks Employee
Databricks Employee

If the image is a result of, for example, a plotting library's output, it should just render as-is.

If it's not, then one simple approach is to write a markdown (%md) cell and include a link to the image:

![](url of the image)

Of course this requires that the image be available somewhere to link to. You can write images to /FileStore on DBFS, and they become available at a URL in your workspace starting with /files. Note that this isn't exactly secure though, as anyone in the workspace could potentially see that file. In some cases that's fine.

For small images, you could encode the bytes of the PNG (for example) image in base64 and then construct a a "data:" URI with that image data. That becomes a self-contained URI you can render in HTML in a markdown cell like any other image. That's only a good idea for pretty small images though.

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now