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
Honored Contributor II
Honored Contributor II

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
Honored Contributor II
Honored Contributor II

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 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!