How to display a svg image?

854 views
Skip to first unread message

Jean-Patrick Pommier

unread,
Jan 21, 2014, 8:40:03 AM1/21/14
to sage-...@googlegroups.com
Hello,
I tried different things to display a svg image stored in a project, none of them succeed.
Is there a way to do it?

Thank you

Jean-Patrick

from IPython.display import SVG
carte
= SVG(filename='2014-01-21-cartes/queen_of_spades_fr.svg')
type
(carte)

import matplotlib.pylab as plt
from IPython.display import Image
im
= Image('2014-01-21-cartes/queen_of_spades_fr.svg')
#plt(im)
#html('carte')
html
("<img src='2014-01-21-cartes/queen_of_spades_fr.svg' />")




<class 'IPython.core.display.SVG'>
Error in lines 5-5
Traceback (most recent call last):
 File "/projects/1e1b74d6-74c0-45b5-99c3-0173b5eeab81/.sagemathcloud/sage_server.py", line 680, in execute
 exec compile(block+'\n', '', 'single') in namespace, locals
 File "", line 1, in <module>
 File "/usr/local/sage/sage-5.13.rc0/local/lib/python2.7/site-packages/IPython/core/display.py", line 597, in __init__
 raise ValueError("Cannot embed the '%s' image format" % (self.format))
ValueError: Cannot embed the 'svg' image format


Harald Schilly

unread,
Jan 21, 2014, 8:58:59 AM1/21/14
to sage-...@googlegroups.com
If your sagews file is in your home directory (not the subdirectory)
this should do the trick:

salvus.file("2014-01-21-cartes/queen_of_spades_fr.svg")

Harald
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cloud" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-cloud+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cloud/0b027fde-e5d9-451b-a0c8-69fa9eff1902%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Jean-Patrick Pommier

unread,
Jan 21, 2014, 9:48:00 AM1/21/14
to sage-...@googlegroups.com
No image is displayed.

To check what's going on:
As a user there different projects. In one of them ("2TUSEN"), when typing "ls" in the terminal command, I get:
00_remédiation.sagews
01_prise de contact.sagews
021-Resolution graphique d'une equation.sagews
02_EquationsDeg1.sagews
030 Probabilité.sagews
03 Inequations.sagews
2013-12-13-145131
2014-01-21-cartes

Then "cd 2014-01-21-cartes" followed by "ls" yields:

01_of_clubs_01.svg
01_of_diamonds_01.svg
01_of_diamonds_A.svg
01_of_hearts_01.svg
01_of_hearts_A.svg
01_of_spades_01.svg
01_of_spades_A.svg
02_of_clubs.svg
.....
From the worksheet "030 Probabilité.sagews": the following code sees the files
import os
cardsList
= os.listdir('2014-01-21-cartes')
print cardsList
The web browser is firefox 26.0 in ubuntu 13.10.


jeanpat

William Stein

unread,
Jan 21, 2014, 9:53:09 AM1/21/14
to sage-...@googlegroups.com

It could be a Unicode issue.  What is the project id, so I can test this myself directly?

> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cloud/6a17f437-ba0e-4317-9a1b-967f71568365%40googlegroups.com.

Jean-Patrick Pommier

unread,
Jan 21, 2014, 10:01:31 AM1/21/14
to sage-...@googlegroups.com
Here it is:

1e1b74d6-74c0-45b5-99c3-0173b5eeab81

Does it matter if it's private.

jp

William Stein

unread,
Jan 21, 2014, 10:02:20 AM1/21/14
to sage-...@googlegroups.com


On Jan 21, 2014 7:01 AM, "Jean-Patrick Pommier" <jeanpatri...@gmail.com> wrote:
>
> Here it is:
>
> 1e1b74d6-74c0-45b5-99c3-0173b5eeab81
>
> Does it matter if it's private.
>

Not to me...

> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cloud/74d1081e-f367-4715-9f30-cd0f7a862ca9%40googlegroups.com.

Jean-Patrick Pommier

unread,
Jan 22, 2014, 4:53:18 AM1/22/14
to sage-...@googlegroups.com
Displaying a png image succeeds with:

salvus.file("2014-01-22-cartes png/07_of_spades.png")
But
salvus.file("2014-01-22-cartes png/07_of_spades.svg")

failed to show an image (no error message). I just have to convert svg to png prior uploading some images.

jp

Harald Schilly

unread,
Jan 22, 2014, 4:56:23 AM1/22/14
to sage-...@googlegroups.com

What browser/OS are you working with?

Harald

Jean-Patrick Pommier

unread,
Jan 22, 2014, 6:04:28 AM1/22/14
to sage-...@googlegroups.com
firefox 26.0 in ubuntu 13.10
Reply all
Reply to author
Forward
0 new messages