ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 21 Oct 2013 03:22:17 +0200How can I show any image in sage notebook via html?https://ask.sagemath.org/question/10627/how-can-i-show-any-image-in-sage-notebook-via-html/Hello!
I type in sage notebook 5.12 (linux mint 15 cinnamon):<br>
html("<img src='1.png'></img>")
If 1.png is placed in DATA path, my code works fine.<br>
When 1.png is placed in any other path, I can't do anything my code work.<br>
Is it possible to show any image in sage notebook via html code?<br>
I need html to create html output with images from my functions.<br>
Please help me. Thanks a lot!)Sun, 20 Oct 2013 07:25:10 +0200https://ask.sagemath.org/question/10627/how-can-i-show-any-image-in-sage-notebook-via-html/Answer by vdelecroix for <p>Hello!
I type in sage notebook 5.12 (linux mint 15 cinnamon):<br/></p>
<pre><code>html("<img src='1.png'></img>")
</code></pre>
<p>If 1.png is placed in DATA path, my code works fine.<br/>
When 1.png is placed in any other path, I can't do anything my code work.<br/>
Is it possible to show any image in sage notebook via html code?<br/>
I need html to create html output with images from my functions.<br/>
Please help me. Thanks a lot!)</p>
https://ask.sagemath.org/question/10627/how-can-i-show-any-image-in-sage-notebook-via-html/?answer=15569#post-id-15569Hello,
If you create your image from a function, then you can sage them in DATA.
P = line([(0,0),(1,1)], color='red')
P.save(DATA + 'my_picture.png')
and then use the code you mentioned
html("<img src='my_picture.png'></img>")
Otherwise, if you want to use pictures from another repository, I am not sure that it is possible.Sun, 20 Oct 2013 09:41:26 +0200https://ask.sagemath.org/question/10627/how-can-i-show-any-image-in-sage-notebook-via-html/?answer=15569#post-id-15569Comment by AndreWin for <p>Hello,</p>
<p>If you create your image from a function, then you can sage them in DATA.</p>
<pre><code>P = line([(0,0),(1,1)], color='red')
P.save(DATA + 'my_picture.png')
</code></pre>
<p>and then use the code you mentioned</p>
<pre><code>html("<img src='my_picture.png'></img>")
</code></pre>
<p>Otherwise, if you want to use pictures from another repository, I am not sure that it is possible.</p>
https://ask.sagemath.org/question/10627/how-can-i-show-any-image-in-sage-notebook-via-html/?comment=16897#post-id-16897I have another task so I tell about it in more detail. I create my own technical library of functions for sage. Any user copy my files in required places to have my functions working. I should have only one place with my images for docstring of my function. My library isn't for online version of sage. Also I don't need to share these images for docstring - other user should copy and install my files. So it's not good to have images for my docstring in DATA folder (there are new DATA folder for each new worksheet and after user delete help function in code, images for docstring are still in DATA).Mon, 21 Oct 2013 03:15:57 +0200https://ask.sagemath.org/question/10627/how-can-i-show-any-image-in-sage-notebook-via-html/?comment=16897#post-id-16897Comment by AndreWin for <p>Hello,</p>
<p>If you create your image from a function, then you can sage them in DATA.</p>
<pre><code>P = line([(0,0),(1,1)], color='red')
P.save(DATA + 'my_picture.png')
</code></pre>
<p>and then use the code you mentioned</p>
<pre><code>html("<img src='my_picture.png'></img>")
</code></pre>
<p>Otherwise, if you want to use pictures from another repository, I am not sure that it is possible.</p>
https://ask.sagemath.org/question/10627/how-can-i-show-any-image-in-sage-notebook-via-html/?comment=16903#post-id-16903Thank you very much, but I know how to use DATA. The help information and pictures aren't in DATA so I should use them from other places.Sun, 20 Oct 2013 09:57:17 +0200https://ask.sagemath.org/question/10627/how-can-i-show-any-image-in-sage-notebook-via-html/?comment=16903#post-id-16903Comment by vdelecroix for <p>Hello,</p>
<p>If you create your image from a function, then you can sage them in DATA.</p>
<pre><code>P = line([(0,0),(1,1)], color='red')
P.save(DATA + 'my_picture.png')
</code></pre>
<p>and then use the code you mentioned</p>
<pre><code>html("<img src='my_picture.png'></img>")
</code></pre>
<p>Otherwise, if you want to use pictures from another repository, I am not sure that it is possible.</p>
https://ask.sagemath.org/question/10627/how-can-i-show-any-image-in-sage-notebook-via-html/?comment=16902#post-id-16902In the notebook, the variable DATA is a Python string that points to the data directory of your worksheet. It is simply some directory on your computer. The simplest would be that you copy your files to that directory (either by a direct copy or using the menu "data" in the worksheet). The reason why this directory exists is that you will be able to save and share your worksheet with the pictures.Sun, 20 Oct 2013 10:15:49 +0200https://ask.sagemath.org/question/10627/how-can-i-show-any-image-in-sage-notebook-via-html/?comment=16902#post-id-16902Answer by AndreWin for <p>Hello!
I type in sage notebook 5.12 (linux mint 15 cinnamon):<br/></p>
<pre><code>html("<img src='1.png'></img>")
</code></pre>
<p>If 1.png is placed in DATA path, my code works fine.<br/>
When 1.png is placed in any other path, I can't do anything my code work.<br/>
Is it possible to show any image in sage notebook via html code?<br/>
I need html to create html output with images from my functions.<br/>
Please help me. Thanks a lot!)</p>
https://ask.sagemath.org/question/10627/how-can-i-show-any-image-in-sage-notebook-via-html/?answer=15575#post-id-15575It seems I found the answer!)<br>
In Firefox browser I pressed ctrl+U to get html code of sage worksheet web page. Then I pressed ctrl+F (the search) and typed "img" (without quotes). I found that image (logo of sage at left top corner of sage worksheet) is sagenb.png. After that in terminal:<br>
locate sagenb.png
The result for me from locate function is:<br>
/home/andrei/sage-5.10/devel/sagenb-main/sagenb/data/sage/images/sagenb.png<br>
So this image folder is that place where I can store my image files.Mon, 21 Oct 2013 03:22:17 +0200https://ask.sagemath.org/question/10627/how-can-i-show-any-image-in-sage-notebook-via-html/?answer=15575#post-id-15575