<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to show an image in a notebook using html? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27496#M19362</link>
    <description>&lt;P&gt;@Paul Hernandez​&amp;nbsp;@Sean Owen​&amp;nbsp;@Navneet Tuteja​&amp;nbsp;I solved this after I also ran into the same issue where my notebook suddenly wouldn't show an image sitting on the driver in an accessible folder - no matter what I was trying in the notebook the display function only returned &amp;lt;IPython.core.display.Image object&amp;gt; as output. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After investigating, I found the file was returning as raw bytes instead of the formatted image (even though it was saved as a png it was raw bytes). Even after encoding for mimetypes manually as well as a few other format conversion attempts it still only rendered &amp;lt;IPython.core.display.Image object&amp;gt; and no image. Like huh?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Solution (Verified using Community Edition):&lt;/P&gt;&lt;P&gt;Reviewing Ipython.display driver dependencies to see if the runtime itself was having issues was successful, as &lt;B&gt;simply updating the cluster's runtime from [Databricks 8.3 (includes Apache Spark 3.1.2, Scala 2.12)] to [8.4 (includes Apache Spark 3.1.2, Scala 2.12)] which gave me a fresh install of Ipython.display in the notebook,  the png/images referenced in the notebook started rendering as normal again. Go down to 8.2 did not fix the display render. &lt;/B&gt;The likely root cause appeared to be mimetype conversion, usually handled by Ipython.display in the call, so if you take a look at your file you may see raw bytes even though the file type is assigned (png in my case), which means the file's raw data isn't being formatted/converted properly and the notebook returns an object to render instead of a supported file format. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Summary: Refresh Ipython to a newer version by updating to a newer runtime may solve the problem, assuming everything in notebook is correct.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Oct 2021 16:39:09 GMT</pubDate>
    <dc:creator>_robschaper</dc:creator>
    <dc:date>2021-10-12T16:39:09Z</dc:date>
    <item>
      <title>How to show an image in a notebook using html?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27489#M19355</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt; Hi everyone, &lt;/P&gt;
&lt;P&gt; I just learning how to personalize the databricks notebooks and would like to show a logo in a cell.&lt;/P&gt;
&lt;P&gt; I installed the databricks cli and was able to upload the image file to the dbfs:&lt;/P&gt;
&lt;P&gt; &lt;span class="lia-inline-image-display-wrapper" image-alt="0693f000007OoKMAA0"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2520i3CF25F1B8CD5D9E2/image-size/large?v=v2&amp;amp;px=999" role="button" title="0693f000007OoKMAA0" alt="0693f000007OoKMAA0" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I try to display it like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;displayHTML("&amp;lt;img src ='files/Omnetric_logo.jpg'&amp;gt;")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is not working:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0693f000007OoKNAA0"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2511i3450F94EC1FC6EC9/image-size/large?v=v2&amp;amp;px=999" role="button" title="0693f000007OoKNAA0" alt="0693f000007OoKNAA0" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If I used the full URI of the image, same result:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;displayHTML("&amp;lt;img src ='dbfs:/FileStore/files/Omnetric_logo.jpg'&amp;gt;")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I also tried with a "images" folder instead of "files", again, same result.&lt;/P&gt;
&lt;P&gt;Could you please help me with that. Any comment will be appreciated.&lt;/P&gt;
&lt;P&gt;Best, &lt;/P&gt;
&lt;P&gt;Paul&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2019 19:13:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27489#M19355</guid>
      <dc:creator>PaulHernandez</dc:creator>
      <dc:date>2019-11-28T19:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to show an image in a notebook using html?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27490#M19356</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hi @Paul Hernandez,&lt;/P&gt;&lt;P&gt;Please use IPython library as in below,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;from IPython.display import Image 
from IPython.core.display import HTML 
Image(url= "https://docs.databricks.com/_images/landing-aws.png")&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Dec 2019 06:49:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27490#M19356</guid>
      <dc:creator>shyam_9</dc:creator>
      <dc:date>2019-12-02T06:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to show an image in a notebook using html?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27491#M19357</link>
      <description>&lt;P&gt;Hi @Shyamprasad Miryala​&amp;nbsp;, thanks for your input!&lt;/P&gt;&lt;P&gt;I gave you a point because your code is working and helped me workaround the issue.&lt;/P&gt;&lt;P&gt;However, I still would like to know why the approach using html and images stored in dbfs is not working, therefore I could not mark your solution as the answer. &lt;/P&gt;&lt;P&gt;Best, Paul&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 10:22:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27491#M19357</guid>
      <dc:creator>PaulHernandez</dc:creator>
      <dc:date>2019-12-02T10:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to show an image in a notebook using html?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27492#M19358</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi @Paul Hernandez, please try adding a preceding slash before the &lt;PRE&gt;&lt;CODE&gt;files&lt;/CODE&gt;&lt;/PRE&gt; path:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;displayHTML("&amp;lt;img src ='/files/Omnetric_logo.jpg'&amp;gt;")
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Just to add as a design pattern - I like to have any static content contained in a markdown block. Most notebooks/workshops I've seen produced by Databricks also do this. That is, you would use the &lt;PRE&gt;&lt;CODE&gt;%md&lt;/CODE&gt;&lt;/PRE&gt; magic command at the top of your block and allow markdown to render the html, along with any other markdown you like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;%md
&amp;lt;img src ='/files/Omnetric_logo.jpg'&amp;gt;
# Hello Omnetric
## Overview
Blah Blah Blah
- list item 1
- list item 2
## Details
Blah blah&lt;/CODE&gt;&lt;/PRE&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 16:45:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27492#M19358</guid>
      <dc:creator>lee</dc:creator>
      <dc:date>2019-12-02T16:45:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to show an image in a notebook using html?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27493#M19359</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi &lt;A href="https://users/31623/leedabee.html" target="_blank"&gt;@leedabee&lt;/A&gt;, &lt;/P&gt;
&lt;P&gt;thanks! I used your snippet for my notebook and it works.&lt;/P&gt;
&lt;P&gt;I also had to correct the url of the image. Since I uploaded the file in dbfs:/FileStore and then in a subfolder called images, the right url is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;/files/files/Omnetric_logo.jpg&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Reviewing the documentation I noticed that &lt;I&gt;dbfs:/FileStore&lt;/I&gt; is mapped to &lt;I&gt;files&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;Best, Paul&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2019 12:34:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27493#M19359</guid>
      <dc:creator>PaulHernandez</dc:creator>
      <dc:date>2019-12-03T12:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to show an image in a notebook using html?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27494#M19360</link>
      <description>&lt;P&gt;Hi @Paul Hernandez​&amp;nbsp;, Did you find a resolution to displaying the images? Image('xyz.png') results with &amp;lt;IPython.core.display.Image object&amp;gt; and no image.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 08:12:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27494#M19360</guid>
      <dc:creator>NavneetTuteja</dc:creator>
      <dc:date>2020-05-13T08:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to show an image in a notebook using html?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27495#M19361</link>
      <description>&lt;P&gt;For small images, another cheeky alternative is to base64-encode the image bytes and construct a data:/ URI out of it, and make a hyperlink to that. It is 'inline' in the notebook then, but, wouldn't be a good idea for big images.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 23:58:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27495#M19361</guid>
      <dc:creator>sean_owen</dc:creator>
      <dc:date>2021-09-15T23:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to show an image in a notebook using html?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27496#M19362</link>
      <description>&lt;P&gt;@Paul Hernandez​&amp;nbsp;@Sean Owen​&amp;nbsp;@Navneet Tuteja​&amp;nbsp;I solved this after I also ran into the same issue where my notebook suddenly wouldn't show an image sitting on the driver in an accessible folder - no matter what I was trying in the notebook the display function only returned &amp;lt;IPython.core.display.Image object&amp;gt; as output. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After investigating, I found the file was returning as raw bytes instead of the formatted image (even though it was saved as a png it was raw bytes). Even after encoding for mimetypes manually as well as a few other format conversion attempts it still only rendered &amp;lt;IPython.core.display.Image object&amp;gt; and no image. Like huh?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My Solution (Verified using Community Edition):&lt;/P&gt;&lt;P&gt;Reviewing Ipython.display driver dependencies to see if the runtime itself was having issues was successful, as &lt;B&gt;simply updating the cluster's runtime from [Databricks 8.3 (includes Apache Spark 3.1.2, Scala 2.12)] to [8.4 (includes Apache Spark 3.1.2, Scala 2.12)] which gave me a fresh install of Ipython.display in the notebook,  the png/images referenced in the notebook started rendering as normal again. Go down to 8.2 did not fix the display render. &lt;/B&gt;The likely root cause appeared to be mimetype conversion, usually handled by Ipython.display in the call, so if you take a look at your file you may see raw bytes even though the file type is assigned (png in my case), which means the file's raw data isn't being formatted/converted properly and the notebook returns an object to render instead of a supported file format. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Summary: Refresh Ipython to a newer version by updating to a newer runtime may solve the problem, assuming everything in notebook is correct.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 16:39:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-show-an-image-in-a-notebook-using-html/m-p/27496#M19362</guid>
      <dc:creator>_robschaper</dc:creator>
      <dc:date>2021-10-12T16:39:09Z</dc:date>
    </item>
  </channel>
</rss>

