Skip to table of contents |
SVG help
Further information: Commons:Help:SVG
Scalable Vector Graphics is a commonly used file format for providing a geometrical description of an image using basic objects such as labels, circles, lines, curves and polygons. An image can be reduced or enlarged to an arbitrary size, and will not suffer image data loss, nor will it become pixelated. SVG makes an excellent format for artwork, diagrams and drawings. SVG images are defined in XML text files. This means that they can be searched, indexed, scripted, and compressed. Since they are XML files, SVG images can be edited with any text editor, but SVG-based drawing programs are also available. However, the rendering engine used by wiki is not perfect, and may cause the image to be shown incorrectly, or differently from how it is displayed in your vector editor of choice. This page enables authors experiencing problems with SVG graphics to obtain some help in getting their images into wiki the way they intend. |
Things we can help with
Understanding SVG
Using SVG appropriately
What you see is not what you get
Something new
| ||||||
Generating SVG filesThere are two classes of problems with using tools to generate SVG files. The first is that tools may generate SVG files that are hard to localize or bloat SVG file size. The second is that the SVG files generated may not be rendered correctly by wikimedia software as PNGs for embedding in Wikipedia pages. This section includes guidance on using software to generate SVG files, including post processing cleanup in a text editor that may be necessary to get a good result. Changing SVG filesSVG files are readily viewable in text editors. To alter a file without disrupting them on Wikimedia, download the file, open it in a text editor to experiment with your text changes, and review the changes in a browser before uploading a new version. For involved edits, you can use a non-destructive editor like Inkscape. Other editors may digest the code and produce outputs in their own SVG format, introducing bugs in the process. Inkscape SVG filesThere is a simple work-around for the scarcities of librsvg. The operation "Stroke to Path", to be found under Menu>Path in Inkscape or via Ctrl+Alt+C, can be applied to all of the objects that are not rendered correctly. To keep the SVGs editable, this should only be done to the files intended for upload, and these files can be deleted afterwards. As of February 2014, the objects that must be modified to render correctly by librsvg include:
OpenOffice.org SVG filesOpenOffice.org SVG files may require manual modification before being uploaded to Wikipedia. To achieve this:
NB: Vector graphics line widths may also need to be set explicitly in OpenOffice.org Draw. SVG code replacement guide (executing replace all using Nedit regular expressions)
This SVG export procedure has been tested using OO 2.3.0 and OO 3.2.1 with a simple .odg candidate. Microsoft Powerpoint SVG filesIt is easiest to save entire slides from Powerpoint as svg rather than saving multiselected objects with right click / save as picture, because for entire slides the boundaries will be cropped to the size of the slide and the background will be set to white. To save slides as svg, use file / save as / browse / save as type --> svg.
If your slide has text, open the exported svg into Notepad and replace all the existing font-family specifications with
Text can also get chopped up on export, which causes rendering and localization bugs. To fix this, search for all Microsoft Visio SVG filesGenerating SVG charts from Microsoft Excel
Pie chart
Scatterplot
I've uploaded .xlsx (Microsoft Excel) spreadsheets that automatically generate XML code for charts in SVG format. You simply paste or enter your data into the spreadsheet, and specify image dimensions, number of grid lines, font sizes, etc. The spreadsheet instantly and automatically generates a column of XML code that you simply copy and paste into a text editor and save as an ".svg" file. The spreadsheets produce lean SVG code, avoiding the "extra stuff" that Inkscape inserts. They should save you time in creating SVG charts. Feedback and suggestions on my talk page are welcome. RCraig09 (talk) 23:41, 19 February 2021 (UTC)Reply
Click HOW TO for detailed explanation.
Example SVG files: Category:SVG diagrams created with spreadsheet.
Text guidanceUse text over pathsConverting text in an SVG file into paths (shapes) increases file size and prevents localization and accessibility features like text to speech, and is therefore generally disfavored (except for text logos, etc.) The wikimedia text rendering engine can introduce bugs as its fonts may differ from browser fonts or SVG editor fonts, but following the guidance below should minimize them. font-family property![]() Due to copyright restrictions, MediaWiki cannot use proprietary fonts that are commonly found on several proprietary operating systems. Fonts such as Geneva require licensing fees to distribute. rsvg will not be able to locate such fonts, and the text will fail to appear in the rendered image. There are three solutions to this issue:
For ease of subsequent editing and significantly smaller file sizes, substituting the font with an available font is recommended. Many common fonts have non-proprietary alternatives that are similar in typographical style, resulting in minimal disruption to existing images during substitution. For a list of fonts available in Wikipedia, see available fonts on Meta. Wikimedia has default fonts, and will use Liberation Serif for Times New Roman and Liberation Sans for Arial. For further fallbacks see c:Help:SVG#fallback. Fonts that are available on Wikimedia servers may or may not be available on a visitor's machine. If the placement or appearance of text in the image is important and there is uncertainty about which fonts are installed on a visitor's machine, then converting text into path information may be necessary. font-size property![]() font-size="35" (or larger) appears to avoid this problem, depending on the pixel size of your graphic.Fonts should be sized so that they look good as thumbnails on wikipedia pages and so they are easy to view on smartphones. Smartphones are how most people access wikipedia. Thumbnails are how most other people see images, as very few people click images and zoom them in to see them. Avoid using or creating images with fonts that are too small to be legible in thumbnail or smartphone views. The font size that appears in a thumbnail is a combination of svg width, thumbnail width, and font size. To match wikipedia font size as a thumbnail, use font-size = (63/(your upright value))*((your svg width)/1000). For instance, if the thumbnail will be scaled up to thumb upright=1.35 and your image has svg width of 960, set font-size in the svg to (63/1.35)*(960/1000) = 44.8. Background colorsTransparent backgrounds are fine, but do not think your image will always be displayed on a light or white background. The wikipedia smartphone app, for instance, renders images on a black background, so if you show black text on a transparent background it will be invisible. Testing for problemsThe following SVG checkers may help you to detect SVG problems before you upload: None of these checkers are foolproof, so it's wise to validate images. You can preliminarily validate images by uploading them to the shared, temporary-use location Test.svg, though other users may overwrite your image at any time. To force refresh images in your browser use Ctrl+F5 (Shift-Reload on Mac), so that you see the latest upload and not cached image copies (this is necessary even on wikimedia upload pages). Rendering SVG filesOn Wikipedia SVGs are interpreted by the librsvg-library to create PNG previews at different image sizes (torasterize them). That library only recognizes a subset of all valid SVG syntax, and may render your SVG without many features. In order to bypass these deficiencies in the library, there are certain parameters that need to be formatted in specific ways or be assigned a workaround value in order for librsvg to accurately render views of your SVG file. Some issues are enumerated below, but be sure to test your SVG files before and after uploading them. <mask> parameter maskUnits="userSpaceOnUse"
The librsvg-library does not interpret the value of parameter stroke-dasharray
The librsvg-library does not accepta
Use xlink:href=, not href= alone, in |
If you have a tricky SVG file with a problem not described, or can't quite figure out what the previous section was talking about, you can simply ask for assistance by posting a quick note hereafter that outlines the problem, as well as providing links to the files that are exhibiting these problems. Don't forget to sign your name with four tilde symbols (~~~~) and an editor will attempt to reply here to help!
When you are happy that a request has been fulfilled, just leave a note so that the request can be archived later, as needed.
An alternative source of help is Commons:Graphics village pump.
|
This page has archives. Sections older than 30 days may be automatically archived by Lowercase sigmabot III when more than 4 sections are present. |
See: File:World Population Prospects.svg
The right-most word "interval" in the text box is missing the last letter due to it being cut off by the right side of the box. That right side needs to be moved over a bit.
It is the same at the source page:
--Timeshifter (talk) 22:11, 24 November 2023 (UTC)Reply
My file File:Butafenacil_synthesis.svg on Commons has the misaligned text problem mentioned above. I'm not competent to fix it. As you can see from the thumbnail, two of the F symbols in the first compound are moved right compared to the original. Please can someone apply one of the work-arounds. Mike Turnbull (talk) 16:01, 4 December 2023 (UTC)Reply
mix-blend-mode
not working?
Hello! I recently tried vectorizing the logo of Sunflower, a really cool tool by a really cool person called Fastily, and I used mix-blend-mode="multiply"
, and it seemed to work in my SVG viewer, but to my shock it doesn't render properly on Commons/Wikipedia.
Any suggestions? QuickQuokka [talk • contribs] 19:20, 5 December 2023 (UTC)Reply
<style>
tag and in a style
property,. but to no avail. QuickQuokka [talk • contribs] 19:22, 5 December 2023 (UTC)Reply
mix-blend-mode
is not a valid attribute for the ellipse
element in SVG 1.1, and I don't think that it's valid in SVG 2.0 either - where did you hear about it? --Redrose64 🌹 (talk) 20:23, 6 December 2023 (UTC)Reply
mix-blend-mode:
property is only described in Compositing and Blending Level 1, which is a W3C Candidate Recommendation; as such, it is not yet a formal part of CSS. Even so, librsvg is very picky about CSS: you may only use those properties and values which are explicitly described either in SVG 1.1 or CSS Level 1. Although the latter is officially superseded in its entirety by CSS 2.0, not all CSS 2.0 features are recognised by librsvg.<ellipse mix-blend-mode="multiply" />
, mix-blend-mode is an attribute to the ellipse tag; in <ellipse style="mix-blend-mode:multiply" />
, mix-blend-mode is a property within the style attribute. You need to use the latter form if something is defined in CSS Level 1 but not in SVG 1.1. --Redrose64 🌹 (talk) 21:06, 6 December 2023 (UTC)Reply
<ellipse style="..." />
, style is an attribute. If you have a contruct like <style>...</style>
, <style>
is an opening tag; </style>
is a closing tag; and the pair together with the content that they enclose comprise a style element.@QuickQuokka: FYI: phab:T341761 is related to this issue. — Johannes Kalliauer - contrib. 13:40, 25 December 2023 (UTC)Reply
text
are ignoredNote: this is *NOT* the infamous recent text-alignment bug.
In this thumbnail, it can be seen that the text labels are left aligned. Some should be indented as in a tree as I prefixed their labels with  . This non-breaking space has effect when used elsewhere but it seems not here.
Is this a known rsvg bug?
Thanks,
cmɢʟee⎆τaʟκ 16:14, 11 December 2023 (UTC)Reply
I've just learned about a Tecnical needs survey at Wikimedia Commons. I'm not expert enough to articulate the ongoing SVG text rendering problem on WMedia projects, but I thought someone here might be able to use that forum to press for progress in that direction. —RCraig09 (talk) 05:55, 20 December 2023 (UTC)Reply