Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Import an SVG file as a graphics object
ResourceFunction["SVGImport"][path] imports the SVG file at path as a Graphics object. | |
ResourceFunction["SVGImport"][ByteArray[…]] imports the given byte array as contents of an SVG file. | |
ResourceFunction["SVGImport"]["string"] imports the given string as contents of an SVG file. |
"path" | a string corresponding to a file path or URL |
File[…] | a File object |
URL[…] | a URL object |
LocalObject[…] | a LocalObject |
CloudObject[…] | a CloudObject |
"ShowWarnings" | False | whether to show warnings about potential conversion inaccuracies |
"IntermediateFormat" | "PDF" | an intermediate file format to be used during conversion |
Import an SVG file as vector graphics:
In[1]:= |
Out[1]= |
In[2]:= |
Out[2]= |
Import an SVG with formatted text:
In[3]:= |
Out[3]= |
In[4]:= |
Out[4]= |
Import an SVG from the web:
In[5]:= |
Out[5]= |
Import a formula:
In[6]:= |
Out[6]= |
In[7]:= |
Out[7]= |
Import an SVG from a string:
In[8]:= |
Out[8]= |
Import from a byte array:
In[9]:= |
Out[9]= |
Import from a URL:
In[10]:= |
Out[10]= |
Import a CloudObject:
In[11]:= |
Out[11]= |
In[12]:= |
Out[12]= |
Import a LocalObject:
In[13]:= |
Out[13]= |
In[14]:= |
Out[14]= |
By default, warnings about potential conversion issues are not shown. In this example, some complex gradients were not converted correctly:
In[15]:= |
Out[15]= |
See the expected appearance:
In[16]:= |
In[17]:= |
Show warnings to see details about conversion problems:
In[18]:= |
Out[18]= |
By default, SVGImport uses "PDF" as an intermediate format, which sometimes encounters issues with gradients:
In[19]:= |
Out[19]= |
In[20]:= |
Out[20]= |
In[21]:= |
Out[21]= |
Using "PNG" as the intermediate format can improve results in some cases:
In[22]:= |
Out[22]= |
The result will no longer be scalable vector graphics, however:
In[23]:= |
Out[23]= |
"SVG" is a supported format for Export, but not Import:
In[24]:= |
Out[24]= |
In[25]:= |
Out[25]= |
Use SVGImport to import SVG files:
In[26]:= |
Out[26]= |
SVG files contain scalable vector graphics, so the results of SVGImport are scalable as well:
In[27]:= |
Out[27]= |
In[28]:= |
Out[28]= |
In[29]:= |
Out[29]= |
Dynamic JavaScript content will not work:
In[30]:= |
Out[30]= |
Animations are also not supported:
In[31]:= |
Out[31]= |
This work is licensed under a Creative Commons Attribution 4.0 International License