Wikipedia:SVG help
SVG help 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
| ||||||
General suggestionseditThe following is a list of common vector editors and suggested settings for compatibility. The user guide of your chosen program may also be valuable in troubleshooting. BrowserseditMost modern browsers can render SVGs in view-only mode. It may be convenient to set a browser as the default SVG viewer, but you can also paste the file path into the address bar. Please note that even if your browser renders an SVG correctly, it may render differently on Wikipedia. Text editorseditSVG documents are text files, and can be edited like any other text file. Specifically, SVGs are XML documents, which have special support in many text editors. One potential disadvantage to editing SVGs by hand is that previewing your changes is more cumbersome. A rudimentary solution would be to open the SVG file in a browser while working on it, and manually refreshing the document to see the result of changes. InkscapeeditThere 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.orgeditOpenOffice.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)edit
This SVG export procedure has been tested using OO 2.3.0 and OO 3.2.1 with a simple .odg candidate. Microsoft PowerpointeditIt 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 VisioeditGenerating SVG charts from spreadsheet programs such as Microsoft Exceledit![]() Warming stripes (five examples compared) ... in a shape Warming stripes bar chart Bar chart Pie chart Variable-width bar chart Line charts Scatterplot Radar chart I've uploaded spreadsheets that automatically generate XML code for charts in SVG format. Summary: You simply paste or enter your data into the spreadsheet, and specify image dimensions, number of grid lines, data ranges, font sizes, etc. The spreadsheets instantly and automatically generate a column of XML code. You simply copy and paste that code into a text editor and save as an ".svg" file. The spreadsheets produce lean SVG code, and should save you time in creating SVG charts. Though my original spreadsheets are written in Microsoft Excel, I've received reports that they also work if read into other spreadsheet programs. Feedback and suggestions on my talk page are welcome. RCraig09 (talk) 23:41, 19 February 2021 (UTC) Click HOW TO for detailed explanation.
Click here to see an example of how the spreadsheets work, internally.
Example SVG files: Category:SVG graphics created with spreadsheet.
Text guidanceeditUse text over pathseditConverting text in an SVG file into paths (shapes) increases file size, prevents localization/accessibility features, and complicates edits/modifications down the line. It is therefore generally disfavored, with some exceptions, such as text-based logos. The Wikimedia text renderer can introduce bugs as its fonts may differ from browser fonts or SVG editor fonts, but following the guidance below should minimize these errors. font-family propertyedit![]() 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 propertyedit![]() 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 colorseditTransparent 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 problemseditThe 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 fileseditOn Wikipedia SVGs are interpreted by the librsvg-library to create PNG previews at different image sizes (to rasterize 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"editThe librsvg-library does not interpret the value of parameter stroke-dasharrayeditThe librsvg-library does not accept a Use
edit
|
Assistance
editIf 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.
Current requests
edit
This page has archives. Sections older than 30 days may be auto-archived by Lowercase sigmabot III if there are more than 4. |
SVG Upload Issue – Draw.io Diagram Hurdles
editG'day from down unda – I’ve hit a wall trying to export and upload an SVG diagram created in Draw.io (diagrams.net) for use on Wikimedia Commons. I’ve followed all documented best practices, but the UploadWizard either rejects the file, renders it blank, or errors out with “empty file” or preview issues.
This is a clean, historically sourced SVG showing the genealogy of the Australian Cattle Dog, and I’d like to include it as part of a breed lineage article. The file was originally constructed in Draw.io and exported as both `.drawio` format and `.xml`.
Files (Available on Google Drive)
edit- [Draw.io File and XML export (identical)](https://drive.google.com/file/d/100SGMmOZgB-Cmmxy7BZnzHLK--cLiN9p/view?usp=drive_link)
Summary of Issues Encountered
edit- SVG exports fail the UploadWizard:
- UploadWizard reports **“empty file”** or fails silently
- Inkscape opens the file fine, but Commons rejects it
- Upload preview fails — image does not render server-side
- Draw.io adds problematic content:
- Default SVG export includes `<foreignObject>` tags and the `http://www.w3.org/1999/xhtml` namespace, which are not supported by MediaWiki’s librsvg renderer
- Even after disabling “Include a copy of my diagram”, and unchecking “Compressed”, Draw.io inserts XHTML wrappers when formatted text or word wrap is enabled
- Manual cleaning attempts:
- Removed all `<foreignObject>` and stripped metadata using Inkscape and SVGOMG
- Attempted plain-text conversion, but doing so broke label layout and connector alignment
- Used Python to decompress base64-encoded XML embedded inside the file, but the export appears truncated or malformed – resulting in either empty output or a zlib decompression error
- Re-exported in every Draw.io combo: “Formatted text” ON/OFF, “Word wrap” OFF, “Compressed” OFF – still fails to produce a Commons-safe SVG
Tools and Resources Used
edit- SVG help pages
- Commons:Help desk
- [SVGOMG](https://jakearchibald.github.io/svgomg/)
- [Inkscape](https://inkscape.org/)
- Custom Python script to decode base64 and decompress raw XML
Suspected Causes
edit- Draw.io embeds extra metadata even when stripped
- SVG output does not align with MediaWiki’s `librsvg` limitations
- Base64-encoded XML appears incomplete or broken in export (can’t be decompressed)
Request
editWould someone be willing to:
- Help extract or reconstruct this diagram in a Commons-compliant SVG form?
- Or confirm if the diagram can be converted without losing its structure or requiring a full redraw?
This file follows all Wikimedia SVG instructions as far as I can tell — but something in the encoding/export pipeline is throwing the UploadWizard off.
Thanks in advance, — Nodocéphale (talk) 08:47, 4 August 2025 (UTC)
- @Nodocéphale: I can't read the .drawio file that you link. Can you post a link to a screenshot, so we can get an idea of the intended content? (Maybe it will be easier to get someone to start from scratch, etc.). —RCraig09 (talk) 18:07, 4 August 2025 (UTC)
- I was able to view the draw.io file linked above as text but although it looks like xml it looks nothing like svg. Was it created through the draw.io "Export as SVG" command? If not, where is the svg file that was created in this way? —David Eppstein (talk) 18:16, 4 August 2025 (UTC)
- @Nodocéphale: I opened the file in http://app.diagrams.net , did File > Export as > SVG... , deleted all occurrences of xmlns="http://www.w3.org/1999/xhtml" and uploaded it with commons:Special:UploadWizard, as per this thumbnail. The SVG needs some work:
- Increase the font size
- Reduce the right margin
- Tidy up the arrows
- Please also ensure that all images are compatible with CC-BY-SA 4.0.
- Cheers, cmɢʟee⎆τaʟκ 22:53, 4 August 2025 (UTC)
- FYI: I can view the file on the file description page, but when I click on it, the text doesn't show up (in Chrome 138.0.7204.169). ——RCraig09 (talk) 23:08, 4 August 2025 (UTC)
- User:cmglee Thanks again for the incredible help so far — it’s much appreciated. Just one small flag: the second version of the SVG renders without any visible text, which might throw off random readers keen to understand the ACD lineage — just anticipating. The first version shows the structure clearly, while the second looks like a hiccup — text off the grid, so to speak.
- I totally get that this is my project, and I don’t want to add any extra work on your end — but would it be of interest if we had a Commons-safe SVG where:
- FYI: I can view the file on the file description page, but when I click on it, the text doesn't show up (in Chrome 138.0.7204.169). ——RCraig09 (talk) 23:08, 4 August 2025 (UTC)
- text displays correctly,
- image elements are clickable,
- and the whole thing can be dissected or iterated upon by others?
- Happy to do the grunt work myself — just wondering if pointing to a working “debug” SVG (with full text and links intact) might help anyone else down the track.
- Cheers again, Nodocéphale (talk) 01:55, 5 August 2025 (UTC)
- @Nodocéphale: I don't understand what you mean by second version. I see only one version on commons:File:ACD_Origins_3-0-drawio.svg. Indeed, when the SVG is opened directly, the text is absent on Chrome (looks fine on Firefox).
- I'll have a look... cmɢʟee⎆τaʟκ 09:47, 5 August 2025 (UTC)
- @Nodocéphale: Why is it necessary to view the SVG directly in a browser? Won't an rsvg-rendered PNG thumbnail do?
- Re my previous comment, I was mistaken; text is missing in Firefox too, as the SVG uses foreignObject instead of text tags. Strange that rsvg supports them.
- http://drawio.com/doc/faq/svg-export-text-problems explains it and gives some workarounds. As I couldn't find Text Settings: in the SVG export dialog, I exported as PDF instead but the chart was haphazardly spread across multiple pages.
- I next opened File:ACD_Origins_3-0-drawio.svg in Inkscape, saved as a PDF, closed it, opened the PDF and saved as a plain SVG. I found that all but one of the images missing, and the text converted into embedded PNGs.
- Doubtful that I can proceed further besides redrawing the whole file, I'll leave this issue for someone else to pick up.
- Good luck, cmɢʟee⎆τaʟκ 00:07, 6 August 2025 (UTC)
- All good mate, working with InkScape now. That wizard seems happy with exports with text. Reopened the svg in there without any text at all, and rebuilding the file from there. In the future, if one there is, if the plan is to upload on commons, I will steer clear from Drawio unless they solved the problem depending on their marketing targets. Will post it in here for a technical review and then will make my way to the Teahouse so we can check policy and formatting. Now just saying, InkScape is very complex and missing the easy to find features from Drawio. Nodocéphale (talk) 01:08, 6 August 2025 (UTC)
- Up for technical review gents
Histogram not yet to fit commons, only for review purposes (Australian Cattle Dog)
- Up for technical review gents
- All good mate, working with InkScape now. That wizard seems happy with exports with text. Reopened the svg in there without any text at all, and rebuilding the file from there. In the future, if one there is, if the plan is to upload on commons, I will steer clear from Drawio unless they solved the problem depending on their marketing targets. Will post it in here for a technical review and then will make my way to the Teahouse so we can check policy and formatting. Now just saying, InkScape is very complex and missing the easy to find features from Drawio. Nodocéphale (talk) 01:08, 6 August 2025 (UTC)
Risley Prism scan pattern animation
editI made an animation of the scan pattern of Risley prisms. However, the thumbnail looks very bad. Can someone figure out how to make the thumbnail look nicer? I understand that we can't have animated SVGs in the thumbnail, but at least, it should look nice. The Python source code used to generate the animation is in the file page. dllu (t,c) 03:27, 27 August 2025 (UTC)
- @Dllu: According to http://svgwg.org/svg2-draft/paths.html#PathLengthAttribute , the
pathLength
attribute used in the file is in the SVG 2 draft. As rsvg, our PNG thumbnail generator supports up to SVG 1.1, it ignores it. - Consequently, the path is drawn as a dashed curve, the
stroke-dasharray
value of 1000 making each dash 1000 units long followed by a gap of 1000 units. - To work around the behaviour, one has to measure the length of the path (or eyeball it by trying out various values and doing binary search), and set
stroke-dasharray
,stroke-dashoffset
andfrom
in theanimate
tag to that value. - Regardless, the SVG is excessively large at 3.84 MB. Can you reduce the number of points and their decimal places?
- Cheers, cmɢʟee⎆τaʟκ 19:32, 27 August 2025 (UTC)
- Thanks, I reduced the file size 10x with a shorter path and fewer decimal points and I measured the path length exactly in my Python script. Cheers! dllu (t,c) 20:33, 27 August 2025 (UTC)
dominant-baseline:central is unsupported
editHi SVG experts,
I've just learnt that setting dominant-baseline:central
is a better alternative to using y="0.7ex"
or dy="0.7ex"
to vertically centre text labels. According to http://www.w3.org/TR/SVG11/text.html#BaselineAlignmentProperties , it's in SVG 1.1 but when I used it in the first version of File:Nicomachus_theorem_2D.svg, our rsvg ignores it. Can someone please confirm if it's really unsupported or did I do things incorrectly?
Thanks, cmɢʟee⎆τaʟκ 19:20, 27 August 2025 (UTC)