Help:SVG
From Wikimedia Commons, the free media repository
|
This page in other languages:
|
SVG (scalable vector graphics) is an accepted file format on Wikimedia Commons. It is suited to diagrams, maps, and other non-photographic images.
SVG files are used quite extensively on Wikimedia Commons. Here are a few tips to get started.
Contents |
[edit] What is SVG?
Scalable vector graphics (SVG) is an XML specification and file format for describing two-dimensional vector graphics, both static and animated. It is stored plain-text or compressed (binary). It allows embedding of raster graphics (bitmaps) and text.
See:
- Scalable Vector Graphics for detailed description
- SVG examples
[edit] Creating SVG images for Wikimedia Commons
[edit] Origination & editing
Programs you can use to create SVG images are shown in General editors below. Alternatively you can edit the SVG code directly with a text editor, or IDE.
[edit] Using specific features of SVG
[edit] Bitmaps
For use in Commons, you are not recommended to import bitmap images into SVG files. It is tempting to import, say, a map into SVG, add some text labels and save it as an SVG. Another temptation is to create a diagram with SVG, and then embellished it with an imported bitmaped emblem or logo.
Incorporating bitmaps runs counter to the ideas at Commons:Transition to SVG and any uploaded SVG containing a bitmap is liable to be automatically tagged as BadSVG by the SVGbot, a bot currently under development.
If you have a bitmap you want to incorporate, it may be possible to convert it, or redraw it as an SVG.
- There is some argument against this restriction in Help_talk:SVG#Undesirable_Restrictions as it ignores some valid uses of bitmaps for reference material. It also restricts the future development of SVG interpreters that could extract an included thumbnail. AngleWyrm (talk) 14:41, 3 December 2009 (UTC)
[edit] Animation
SVG images can have animation built in with SMIL, but because the .svg is converted to .png for use in Wikimedia projects, the animated SVG file is only visible from the image page.
See Tagging SVGs for how to mark it animated.
[edit] Scripting
MediaWiki does not accept SVG files containing scripts.
[edit] External files
Before saving the final version, make sure you delete any references to other files you used to make the SVG; if these references are left behind, then the render is unlikely to be able to find the external file and will fail.
[edit] Tidying up
It's also a good idea to remove or "vacuum" any unused definitions (defs), as this can result in a smaller file size. Scour is an open-source Python script that cleans and optimizes SVG files. There's even an online version so there's nothing to download.
[edit] Plain SVG, compressed SVG, generic specifications
It is generally better to save in "Plain SVG" format. Usually this appears in the program's Save As dialog box as an alternative format (as opposed to just "SVG", which might be program's own version of SVG). This is for reasons of compatibility, amongst other things.
In Adobe Illustrator or Inkscape (especially Illustrator) the default file format includes information (such as user preferences) that is not needed in uploaded files. This increases the file size unnecessarily and sometimes causes thumbnails to not render properly. (See bugzilla:2888.)
On the other hand, saving as "Plain SVG" may lose information useful to you. In Inkscape, for example, it removes layer information and metadata. You may wish to create a plain version just for uploading and keep a 'fancy' master version for your own purposes, or tag with {{Created with Inkscape|IMPORTANT=yes}}. See Help:Inkscape for more.
Inkscape and other programs also allows to save SVGZ (compressed binary SVG), which is not supported on Commons.
[edit] Fonts
Only some fonts can be rendered in the <text> tag. You can find a list here. Please do consider using this font and not converting fonts to path (the latter will increase file dimension and will prevent the generation of localized version of the image).
Text in Inkscape by default uses a Flowed Text box which can result in problems (it will likely not render at all or render as a large black rectangle). To fix this, simply use the Convert To Text command in the Inkscape Text menu.
Alternatively, before typing the text, first select the text tool and with the mouse click without dragging on the canvas where you wish the text to begin.
[edit] Gradients
Users of Inkscape version 0.46 may notice that images with "Fill gradients" display perfectly on Inkscape, but display "messed up" in Opera or Firefox browsers. One possible cause is that the last "stop" on a gradient has opacity set to 0. Inkscape appears to ignore this last stop, but both Firefox 3.0.6 and Opera 9.36 will render it as a white border in the filled object. Solutions are either remove the last stop (because it was probably created in error) or change the opacity (and colour) so that the image renders correctly in browsers.
[edit] Validation
You may wish to put the file through the SVG Validator (http://validator.w3.org/) before you upload. This can tell you about possible problems in your SVG. Unfortunately this validator cannot handle RDF or other metadata, should you wish to include it, but it can still find errors in your SVG. It also wants a Doctype declaration, which is not a requirement in SVG and may actually cause problems.
See Tagging SVGs for how to mark it validated.
[edit] Uploading & categorizing
[edit] Image description pages
Uploading is described at Commons:First steps/Upload form.
Make sure to fill out the {{information}} box as fully as you can. Often, its a help when an image has a complete information box as this makes categorization by others easier and allows others to make translations.
If your file has passed the SVG Validator, you can put the {{validSVG}} tag on the image page.
See the Software tags section for detailed information on a SVG media.
[edit] Categorizing SVGs
|
|
By now, all SVG graphics should be sorted into Category:SVG, but please do not sort directly there, it will become overcrowded and useless. Try some of the thematical subcategories.
Please sort categories, which rely not on subject but on technical aspects ("created with..", "animated", "valid", and so on) by «*» to keep them outside the alphabet
[edit] The SVG categories tree
The main tree is Category:SVG, as a part of Category:Images → Category:Media types.
Concerning thematical subcategories, it is not needful to rebuild the complete hierarchy tree of Category:Topics. Normally, it is enough to gather some topics to one. For instance, Category:SVG colors could contain all color-related SVGs of Category:Colors, its no use to build Category:SVG – red, Category:SVG – blue and so on. Maybe some subcategories will become useful later, but stay close to our existing topics tree, and do not put any SVG files only into a SVG-category: Categories are primarily for finding media, not for hiding them. Do not over-categorize, so do not sort into a category for finding it, and the direct SVG subcategory for classifying, but maybe put your black colour box SVG file into Category:SVG colors and Category:Black.
- See Commons:Categories for general information.
[edit] Naming conventions
There are no naming conventions by now (May 2008), besides beginning with "SVG ". Just do what is reasonable and coherent to our existing categories.
- A discussion on the naming of SVG categories was started in June 2009.
[edit] Tagging SVGs
- See Category:SVG marker templates for all SVG markers available
[edit] SVG software tags
For the software used (Category:SVG graphics by software used):
- {{created with Adobe Illustrator}}, sorts into Category:Created with Adobe Illustrator,
|
This vector graphics image was created with Adobe Illustrator. |
- {{created with CorelDraw}}, sorts into Category:Created with CorelDraw,
|
This vector graphics image was created with CorelDRAW. |
- {{created with Dia}}, sorts into Category:Created with Dia,
|
This diagram document or vector graphics image was created with Dia. |
- {{ElCompLib}}, sorts to Category:Created with electrical symbols library
|
This SVG electrical schematic was created with the electrical symbols library.svg. |
- {{Fig2SVG}}, does not sort by now (May 2008)
|
This SVG vector image was created with Xfig and a Fig to SVG conversion tool. |
- {{gnuplot}}, does not sort by now (May 2008)
|
This vector image was created with gnuplot. |
- {{created with Inkscape}}, sorts into Category:Created with Inkscape, see also {{Inkscape-hand}} (which also sorts into Category:Manually coded SVG)
|
This vector image was created with Inkscape. |
- {{created with OpenOffice.org}}, sorts into Category:Made with OpenOffice.org, pays no attention on SVG or other file formats (May 2008)
|
This file was created with OpenOffice.org. |
- {{created with Sodipodi}}, sorts into Category:Created with Sodipodi
|
This vector image was created with Sodipodi. |
- {{created with Scribus}}, does not sort by now (May 2008), also for typesetting
|
This typeset document or vector graphics image was created with Scribus. |
- For other software, by now categorize as usual, see Commons:Templates#Created with... templates for an summary of software-related templates
See Software section for a list of programs
[edit] SVG file type tags
For making use of elements from other SVG images available on Commons, please use {{attribSVG}} – see Category:Vector images using elements from other vector images
| This vector image includes elements that have been taken or adapted from this: [[Image:|20px|Source SVG image]] [[:Image:|]]. |
All validated SVGs should be tagged {{validSVG}}, you will find them automatically sorted at Category:Valid SVG. Please do not categorize directly.
W3C ✓ The source code of this SVG is valid!
For animations you can use {{animated SVG}}
| This image is an animated SVG. The animation uses SMIL. The .png preview above created by RSVG is not animated and may be incomplete or incorrect. To see the animation run, open media:SVG in an SVG animation capable browser or viewer, such as Opera (8+), Safari (4+), Chrome (2+), or Internet Explorer with Adobe SVG viewer installed. Firefox does not yet support SMIL. Other SVG animations can be found at Category:Animated SVG.
العربية | Català | Deutsch | English | Suomi | Français | Italiano | Íslenska | Magyar | Македонски | Plattdüütsch | Nederlands | Occitan | Português | Русский | Українська | +/− |
SVGs containing JavaScript cannot be uploaded at present, but this template anticipates that possibility {{scripted SVG}}
| This is a scripted SVG file (it contains Javascript). The preview above may be incomplete or incorrect. To use the interactive possibilities open it in an SVG Scripting aware browser or viewer, e.g., Firefox, Opera, or Safari. Internet Explorer can be used with the Adobe SVG plugin installed.
العربية | Deutsch | Deutsch (Sie-Form) | English | Italiano | Македонски | Nederlands | Polski | Português | +/− |
[edit] SVG conversion tags
If you find raster images that should be vector graphics -- especially diagrams, charts, graphs and some drawings -- tag them {{convert to SVG}}
- Specials: For musical notation {{convertToSVG-MN}}, for Nuvola {{N2+SVG}}
For SVGs using embedded bitmaps causing bad quality, use {{badSVG}} and for rasters that have been superseded by an svg, use {{vector version available|File name.svg}}
[edit] SVGs in MediaWiki
[edit] How SVGs work in MediaWiki
When you upload your SVG to Commons (or any other MediaWiki wiki), the software automatically produces PNG thumbnails, embedded in the articles and the description page. If you download the image (usually by right mouse clicking on the image), you will get the PNG image. If you want the SVG file you must save the link to the image instead of the image itself. This works only on the description page of the image, not on the thumbnail in the category page.
MediaWiki uses rsvg to convert SVGs to PNGs for display (SVG-rendering), so you might want to check your file with that program before uploading. The rsvg-view can be used on UNIX systems to preview how SVGs will look when rendered by MediaWiki.
See the SVG image support page on Meta for more.
[edit] Scaling SVGs via MediaWiki
What this means... say you want to produce a large version of your SVG for detailed maps, or using in bitmap software like gimp, or calligraphy printed out one character per page, or something like that. You need to force MediaWiki to produce a huge PNG thumbnail, by using
http://commons.wikimedia.org/w/thumb.php?f=Foo.svg&w=1000
or by doing something like [[Image:Foo.svg|1000px]] in the sandbox or your talk page or somewhere else unimportant. Printing this giant PNG will look much better than if you try to scale up one of the default thumbnails! Off course you can also use for printing SVG software like Inkscape but sometimes the shows something others than on the screen (black background, other fonts, ...).
[edit] Frequently asked questions
- Why doesn't my image render?
- This might be due to a number of reasons. Most often it is due to a reference to an external file, a leftover from tracing a bitmap, perhaps. (The rendering stops as the website tries to find this other file). To solve this problem, in your editor, make sure to remove any references to other files before saving the final version. If it is necessary to use bitmaps you can use in Inkscape the function to embedding all images (Effects menu -> Images -> Embed All Images). See also Plain SVG, Compressed SVG above.
- Where can I get extra help with SVG images?
- Try Commons:Graphic Lab if you have a problem with an individual image. Commons:Graphics village pump can be useful for SVG discussion (as well as graphics in general). Often SVG enthusiasts will be around on those pages, and are more than willing to help.
- How large should my SVG images be?
- The absolute size of the document does not matter much, since that only affects how it is displayed when viewed by itself. The file size does not depend on the document dimensions! The image can be stretched or compressed as much as a user wants, without changing quality, or file size. With that in mind, the recommended image width is around 600px. When a user views the full size image, a width of 600-800px gives them a good close-up view, while still allowing them to fit the entire image on their screen without having to zoom in or out.
- How do you change the document size in Inkscape?
- The document size starts out with an A4 page. To make this larger or smaller, create a rectangle with the dimensions you desire the document to be, and select it with the arrow tool. Then select File>Document Properties, and under Custom Size, choose Fit page to selection, and click OK. You can now delete the "sizing" rectangle, and move or resize the other elements to fit the space you have created.
- My text is appearing as little blocks, or isn't showing up at all after uploading to Commons!
- if you use "Flowed Text" in Inkscape, it will render as a black rectangle. Flowed text boxes are created when you click and drag to make you text box. To avoid this, just click once to position your cursor and then type your text. To convert a flowed text box to a normal text box, go to the "Text" menu and choose "Convert to Text".
- If this still doesn't work, some text features of Inkscape are not supported by MediaWiki's renderer, such as text-on-path. If you are not using flowed text and still have problem, convert the text to paths. Do this by selecting the command Path>Object to Path. This will convert the text to paths. Save as Plain SVG, and reupload your file.
- My arrowheads/dashed lines are appearing as little blocks, or aren't showing up at all after uploading to Commons!
- Some stroke features of Inkscape are not supported by MediaWiki's renderer. Select the offending objects, and select the command Path>Stroke to Path. This will convert the strokes to paths. Save as Plain SVG, and reupload your file.
- How do I get rid of the transparent background?
- Do you really need to? Usually not! MediaWiki's renderer will convert the SVG file to PNG with a transparent white background for display (displays white if your browser doesn't support PNG transparencies). Browsers that natively support SVG transparency will show the background color through the image, white! Leaving your image transparent behind helps future editors, and allows the image to be displayed over other background colors without a big white square. However, if your image really needs a specific colored background, create a rectangle the size of the image, fill it with the background color of your choice, and choose the command Object>Lower to Bottom. Save your image, and enjoy the solid background color!
- My fonts aren't rendering correctly. What fonts are supported by the site's renderer?
- See m:SVG fonts for a list.
- I'm drawing a flag (or some other insignia) and it asks for PANTONE or CMYK colors. What do I do?
- First, if you see the words PANTONE or CMYK, try to see if they have something called RGB. Wikimedia Commons images are used a lot on Wikimedia projects such as Wikipedia, etc, and are designed for use on computer screens. If you can find RGB colors, use them in favour of others. If you can't, you can convert the colors using your program's own color picker, or, in the case of PANTONE, Color Finder (http://www.pantone.com/pages/pantone/colorfinder.aspx), from which you can extract RGB values for a color code.
[edit] Software
Many programs can handle SVG files. You may like to try one given below, though these are not the only programs around. Some are available for free download, while others are commercial software.
As SVG is just an XML specification, it is possible to write SVG files in a text editor. In fact, many SVG images are written in text editors. An editor which can highlight the syntax is helpful.
See Software tags section for information about the software, the SVG file was done with, and specific handling hints.
[edit] Rendering
- rsvg, used by MediaWiki
- rsvg-view can be used on UNIX systems to preview how SVGs will look when rendered by MediaWiki.
- Firefox 2.0, Konqueror (of KDE) and Opera support SVG natively.
[edit] General editors
- SVG can be edited by any text-editor, it is usually stored XML-type plain-text. An editor which can highlight the syntax is helpful.
- Inkscape: An open source, freely downloadable application for graphically editing SVG files. Available on Windows, Mac OS X, and Linux.
- SodiPodi Also for graphically editing SVG files, available on Windows and Linux. Inkscape is based on the Sodipodi-engine.
- OpenOffice.org/StarOffice Draw, an open source, freely downloadable drawing program which comes as part of the the Open Office suite. Can export to SVG, reads SVG with SVG Plugin
- Dia An open source, freely downloadable application for creating diagrams. SVG export optional. Runs on Windows, Mac OS X, and Unix systems. (Currently has some bugs in SVG export.)
- Adobe Illustrator
- CorelDraw
[edit] Specific application
- Graphviz: An open source application for automatic diagram layout.
- BKchem: A free software to draw chemical structures in SVG. Runs on Windows, Mac OS X, and Unix systems.
[edit] Validators
- SVG Validator, by W3C
[edit] Converters
- From raster formats (bitmaps)
- Most SVG-editors include a Raster-to-Vector-converter (Tracer)
- Delineate, a free tracer, it is a Java-based interface for Potrace and Autotrace. Potrace is also implemented into Inkscape (
>Path >Trace Bitmap) - Vector magic: An online free raster to svg converter.
- From other vector formats
- FreeSVG can convert PDFs to SVG via a web interface
- Scribus (with GhostScript) can import EPS (Encapsulated PostScript) files and export them to SVG.
[edit] See also
Technical:
- Commons:File types#SVG - A couple of tips on saving for Commons.
- Commons:Transition to SVG
Specific application:
- Commons:Translation possible/Learn more - Deals with translating SVGs (diagram labels).
- Category:SVG maps – the SVG-branch of the map-project
- m:SVG fonts - A list of supported fonts.
Maintenance:
- Category:Images that should use vector graphics
- Category:Pictures showing a librsvg bug
- Top 200 Non-Icons which have a Vector version available by usage
[edit] External links
[edit] Free sources
- More than 10000 SVG images (public domain) at http://www.openclipart.org/