Scalable Vector Graphics

From The Hidden Wiki
Jump to navigationJump to search

Template:Use dmy dates Template:Infobox file format

Scalable Vector Graphics (SVG) is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation. The SVG specification is an open standard developed by the World Wide Web Consortium (W3C) since 1999.

SVG images and their behaviors are defined in XML text files. This means that they can be searched, indexed, scripted, and compressed. As XML files, SVG images can be created and edited with any text editor, but are more often created with drawing software.

All major modern web browsers—including Mozilla Firefox, Internet Explorer, Google Chrome, Opera, and Safari—have at least some degree of SVG rendering support.

Overview

File:Bitmap VS SVG.svg
This image illustrates the difference between bitmap and vector images. The bitmap image is composed of a fixed set of dots, while the vector image is composed of a fixed set of shapes. In the picture, scaling the bitmap reveals the dots while scaling the vector image preserves the shapes.

SVG has been in development since 1999 by a group of companies within the W3C after the competing standards Precision Graphics Markup Language (PGML, developed from Adobe's PostScript) and Vector Markup Language (VML, developed from Microsoft's RTF) were submitted to W3C in 1998. SVG drew on experience from the designs of both those formats.<ref>Template:Cite web</ref>

SVG allows three types of graphic objects: vector graphics, raster graphics, and text. Graphical objects, including PNG and JPEG raster images, can be grouped, styled, transformed, and composited into previously rendered objects. SVG does not directly support z-indices<ref>Template:Cite web</ref> that separate drawing order from document order for overlapping objects, unlike some other vector markup languages like VML. Text can be in any XML namespace suitable to the application, which enhances search ability and accessibility of the SVG graphics. The feature set includes nested transformations, clipping paths, alpha masks, filter effects, template objects, and extensibility.

Since 2001, the SVG specification has been updated to version 1.1. The SVG Mobile Recommendation introduced two simplified profiles of SVG 1.1, SVG Basic and SVG Tiny, meant for devices with reduced computational and display capabilities. An enhanced version of SVG Tiny, called SVG Tiny 1.2, later became an autonomous Recommendation.<ref name="tiny1.x" />

Work is currently in progress on SVG 2, which incorporates several new features in addition to those of SVG 1.1 and SVG Tiny 1.2.

Printing

Though the SVG Specification primarily focuses on vector graphics markup language, its design includes the basic capabilities of a page description language like Adobe's PDF. It contains provisions for rich graphics, and is compatible with CSS for styling purposes. SVG has the information needed to place each glyph and image in a chosen location on a printed page.<ref>Template:Cite web</ref> (By contrast, XHTML's primary purpose is to communicate content, not presentation, so XHTML specifies objects to be displayed but not where to place them.) A print-specialized subset of SVG (SVG Print, authored by Canon, HP, Adobe and Corel) is Template:As of a W3C Working Draft.<ref>Template:Cite web</ref>

Scripting and animation

Template:Main SVG drawings can be dynamic and interactive. Time-based modifications to the elements can be described in SMIL, or can be programmed in a scripting language (e.g. ECMAScript or JavaScript). The W3C explicitly recommends SMIL as the standard for animation in SVG.<ref>Template:Cite web</ref> A rich set of event handlers such as onmouseover and onclick can be assigned to any SVG graphical object.

Compression

SVG images, being XML, contain many repeated fragments of text, so they are well suited for lossless data compression algorithms. When an SVG image has been compressed with the industry standard gzip algorithm, it is referred to as an "SVGZ" image and uses the corresponding .svgz filename extension. Conforming SVG 1.1 viewers will display compressed images.<ref>See https://www.w3.org/TR/SVG11/conform.html#ConformingSVGViewers which states, "SVG implementations must correctly support gzip-encoded [RFC1952] and deflate-encoded [RFC1951] data streams, for any content type (including SVG, script files, images)."</ref> An SVGZ file is typically 20 to 50 percent of the original size.<ref>Template:Cite web</ref> W3C provides SVGZ files to test for conformance.<ref>For example, https://dev.w3.org/SVG/profiles/1.1F2/test/harness/htmlObject/conform-viewers-01-t.html</ref>

Development history

SVG was developed by the W3C SVG Working Group starting in 1998, after Macromedia and Microsoft introduced VML whereas Adobe Systems and Sun Microsystems submitted a competing format known as PGML. The working group was chaired by Chris Lilley of the W3C.

  • SVG 1.0 became a W3C Recommendation on 4 September 2001.<ref>Template:Cite web</ref>
  • SVG 1.1 became a W3C Recommendation on 14 January 2003.<ref name="svg11">Template:Cite web</ref> The SVG 1.1 specification is modularized in order to allow subsets to be defined as profiles. Apart from this, there is very little difference between SVG 1.1 and SVG 1.0.
  • SVG Tiny 1.2 became a W3C Recommendation on 22 December 2008.<ref>Template:Cite web</ref> It was initially drafted as a profile of the planned SVG Full 1.2 (which has since been dropped in favor of SVG 2),<ref name="ieblog">Template:Cite web</ref> but was later refactored as a standalone specification.
  • SVG 1.1 Second Edition, which includes all the errata and clarifications, but no new features to the original SVG 1.1 was released on 16 August 2011.<ref>https://www.w3.org/TR/2011/REC-SVG11-20110816/</ref>
  • SVG 2 will completely rework draft 1.2 with more integration with new web features such as CSS, HTML5 and WOFF.

The MPEG-4 Part 20 standard - Lightweight Application Scene Representation (LASeR) and Simple Aggregation Format (SAF) is based on SVG Tiny.<ref>Template:Cite web</ref> It was developed by MPEG (ISO/IEC JTC1/SC29/WG11) and published as ISO/IEC 14496-20:2006.<ref>Template:Cite web</ref> SVG capabilities are enhanced in MPEG-4 Part 20 with key features for mobile services, such as dynamic updates, binary encoding, state-of-art font representation.<ref>Template:Cite web</ref> SVG was also accommodated in MPEG-4 Part 11, in the Extensible MPEG-4 Textual (XMT) format - a textual representation of the MPEG-4 multimedia content using XML.<ref>Template:Cite web</ref>

Mobile profiles

Because of industry demand, two mobile profiles were introduced with SVG 1.1: SVG Tiny (SVGT) and SVG Basic (SVGB). These are subsets of the full SVG standard, mainly intended for user agents with limited capabilities. In particular, SVG Tiny was defined for highly restricted mobile devices such as cellphones; it doesn't support styling or scripting.<ref name="tiny1.x">Template:Cite web</ref> SVG Basic was defined for higher-level mobile devices, such as PDAs.

In 2003, the 3GPP, an international telecommunications standards group, adopted SVG Tiny as the mandatory vector graphics media format for next-generation phones. SVGT is the required vector graphics format and support of SVGB is optional for Multimedia Messaging Service (MMS) and Packet-switched Streaming Service.<ref>Template:Cite web</ref><ref>Template:Cite web</ref><ref>Template:Cite web</ref> It was later added as required format for vector graphics in 3GPP IP Multimedia Subsystem (IMS).<ref>Template:Cite web</ref> Neither mobile profile includes support for the full DOM, while only SVG Basic has optional support for scripting, but because they are fully compatible subsets of the full standard, most SVG graphics can still be rendered by devices which only support the mobile profiles.<ref>Template:Cite web</ref>

SVGT 1.2 adds a microDOM (μDOM), styling and scripting.<ref name="tiny1.x" />

Functionality

The SVG 1.1 specification defines 14 functional areas or feature sets:<ref name="svg11" />

Paths
Simple or compound shape outlines are drawn with curved or straight lines that can be filled in, outlined, or used as a clipping path. Paths have a compact coding. For example M (for 'move to') precedes initial numeric x and y coordinates and L (line to) precedes a point to which a line should be drawn. Further command letters (C, S, Q, T and A) precede data that is used to draw various Bézier and elliptical curves. Z is used to close a path. In all cases, absolute coordinates follow capital letter commands and relative coordinates are used after the equivalent lower-case letters.<ref name="path">Template:Cite web</ref>
Basic shapes
Straight-line paths and paths made up of a series of connected straight-line segments (polylines), as well as closed polygons, circles and ellipses can be drawn. Rectangles and round-cornered rectangles are also standard elements.<ref name="shap">Template:Cite web</ref>
Text
Unicode character text included in an SVG file is expressed as XML character data. Many visual effects are possible, and the SVG specification automatically handles bidirectional text (for composing a combination of English and Arabic text, for example), vertical text (as Chinese was historically written) and characters along a curved path (such as the text around the edge of the Great Seal of the United States).<ref name="text">Template:Cite web</ref>
Painting
SVG shapes can be filled and/or outlined (painted with a color, a gradient, or a pattern). Fills can be opaque or have any degree of transparency. "Markers" are line-end features, such as arrowheads, or symbols that can appear at the vertices of a polygon.<ref name="pntg">Template:Cite web</ref>
Color
Colors can be applied to all visible SVG elements, either directly or via 'fill', 'stroke,' and other properties. Colors are specified in the same way as in CSS2, i.e. using names like black or blue, in hexadecimal such as #2f0 or #22ff00, in decimal like rgb(255,255,127), or as percentages of the form rgb(100%,100%,50%).<ref name="colr">Template:Cite web</ref>
Gradients and patterns
SVG shapes can be filled or outlined with solid colors as above, or with color gradients or with repeating patterns. Color gradients can be linear or radial (circular), and can involve any number of colors as well as repeats. Opacity gradients can also be specified. Patterns are based on predefined raster or vector graphic objects, which can be repeated in x and/or y directions. Gradients and patterns can be animated and scripted.<ref name="patt">Template:Cite web</ref>
Since 2008, there has been discussion<ref>Template:Cite web</ref><ref>Template:Cite web</ref> among professional users of SVG that either gradient meshes or preferably diffusion curves could usefully be added to the SVG specification. It is said that a "simple representation [using diffusion curves] is capable of representing even very subtle shading effects"<ref>Template:Cite web</ref> and that "Diffusion curve images are comparable both in quality and coding efficiency with gradient meshes, but are simpler to create (according to several artists who have used both tools), and can be captured from bitmaps fully automatically."<ref>Template:Cite journal</ref> The current draft of SVG 2 includes gradient meshes.<ref>Template:Cite web</ref>
Clipping, masking and compositing
Graphic elements, including text, paths, basic shapes and combinations of these, can be used as outlines to define both inside and outside regions that can be painted (with colors, gradients and patterns) independently. Fully opaque clipping paths and semi-transparent masks are composited together to calculate the color and opacity of every pixel of the final image, using alpha blending.<ref name="mask">Template:Cite web</ref>
Filter effects<ref name="filt">Template:Cite web</ref>
Template:Main
Interactivity
SVG images can interact with users in many ways. In addition to hyperlinks as mentioned below, any part of an SVG image can be made receptive to user interface events such as changes in focus, mouse clicks, scrolling or *****ming the image and other pointer, keyboard and document events. Event handlers may start, stop or alter animations as well as trigger scripts in response to such events.<ref name="intr">Template:Cite web</ref>
Linking
SVG images can contain hyperlinks to other documents, using XLink. URLs of SVG images can specify geometrical transforms in the fragment section.<ref name="link">Template:Cite web</ref>
Scripting
All aspects of an SVG document can be accessed and manipulated using scripts in a similar way to HTML. The default scripting language is ECMAScript (closely related to JavaScript) and there are defined Document Object Model (DOM) objects for every SVG element and attribute. Scripts are enclosed in <script> elements. They can run in response to pointer events, keyboard events and document events as required.<ref name="scrp">Template:Cite web</ref>
Animation
Template:Main
SVG content can be animated using the built-in animation elements such as <animate>, <animateMotion> and <animateColor>. Content can be animated by manipulating the DOM using ECMAScript and the scripting language's built-in timers. SVG animation has been designed to be compatible with current and future versions of Synchronized Multimedia Integration Language (SMIL). Animations can be continuous, they can loop and repeat, and they can respond to user events, as mentioned above.<ref name="anim">Template:Cite web</ref>
Fonts
As with HTML and CSS, text in SVG may reference external font files, such as system fonts. If the required font files do not exist on the machine where the SVG file is rendered, the text may not appear as intended. To overcome this limitation, text can be displayed in an SVG font, where the required glyphs are defined in SVG as a font that is then referenced from the <text> element.<ref name="font">Template:Cite web</ref>
Metadata
In accord with the W3C's Semantic Web initiative, SVG allows authors to provide metadata about SVG content. The main facility is the <metadata> element, where the document can be described using Dublin Core metadata properties (e.g. title, creator/author, subject, description, etc.). Other metadata schemas may also be used. In addition, SVG defines <title> and <desc> elements where authors may also provide plain-text descriptive material within an SVG image to help indexing, searching and retrieval by a number of means.<ref name="meta">Template:Cite web</ref>

An SVG document can define components including shapes, gradients etc., and use them repeatedly. SVG images can also contain raster graphics, such as PNG and JPEG images, and further SVG images.

Example

This code will produce a green square with a black outline: <source lang="xml"> <svg xmlns="https://www.w3.org/2000/svg" version="1.1">

 <rect width="150" height="150" fill="rgb(0, 255, 0)" stroke-width="1" stroke="rgb(0, 0, 0)" />

</svg> </source>

File:Svg example square.svg
A square generated by the SVG code.

SVG on the web

The use of SVG on the web was limited by the lack of support in older versions of Internet Explorer (IE). Many web sites that serve SVG images, such as Wikipedia, also provide the images in a raster format, either automatically by HTTP content negotiation or by allowing the user directly to choose the file.

Google announced on 31 August 2010 that it had started to index SVG content on the web, whether it is in standalone files or embedded in HTML, and that users would begin to see such content listed among their search results.<ref>Template:Cite web</ref> It was announced on 8 December 2010 that Google Image Search would also begin indexing SVG files.<ref>Template:Cite web</ref> On 28 January 2011, it was discovered that Google was allowing Image Search results to be restricted exclusively to SVG files.<ref>Template:Cite web</ref> This feature was announced officially on 11 February 2011.<ref>Template:Cite web</ref>

Native browser support

Konqueror was the first browser to support SVG in release version 3.2 in February 2004.<ref>Template:Cite web</ref> As of 2011, all major desktop browsers, and many minor ones, have some level of SVG support. Other browsers' implementations are not yet complete; see comparison of layout engines for further details.

Some earlier versions of Firefox (e.g. versions between 1.5 and 3.6<ref>Template:Cite journal</ref>), as well as a smattering of other now-outdated web browsers capable of displaying SVG graphics, needed them embedded in <object> or <iframe> elements to display them integrated as parts of an HTML webpage instead of using the standard way of integrating images with <img>.<ref>Template:Cite web</ref> However, SVG images may be included in XHTML pages using XML namespaces.<ref>Template:Cite web</ref>

Tim Berners-Lee, the inventor of the World Wide Web, has been critical of (earlier versions of) Internet Explorer for its failure to support SVG.<ref>*****o</ref>

There are several advantages to native and full support: plugins are not needed, SVG can be freely mixed with other content in a single document, and rendering and scripting become considerably more reliable.<ref>Template:Cite web</ref>

Plug-in browser support

Internet Explorer, up to and including IE8, was the only major browser not to provide native SVG support. IE8 and older require a plug-in to render SVG content. There are a number of plug-ins available to assist, including:

  • Ample SDK Open-Source JavaScript GUI Framework provides partial support for SVG 1.1, SMIL, DOM and style scripting in Internet Explorer (5.5 - 8.0) too. It is not dependent on any plugins and relies on presence of alternative Vector Graphics format VML in Internet Explorer.
  • Batik, a widely deployed Java plugin<ref>Template:Cite web</ref>
  • Google Chrome Frame from Google can support all web elements supported by WebKit, including SVG 1.0 and partially SVG 1.1.
  • GPAC, targets SVGT 1.2<ref name="C4Wauto-512169">Template:Cite web</ref><ref name="C4Wauto-349853">Template:Cite web</ref>
  • Adobe SVG Viewer from Adobe Systems plugin supports most of SVG 1.0/1.1.<ref>Template:Cite web</ref><ref name="AdobeEoL">Template:Cite web</ref> (discontinued)
  • Corel SVG Viewer<ref>Template:Cite web</ref> (discontinued)
  • Raphaël is another JavaScript library that takes advantage of the intersection between VML's and SVG's features to create vector graphics and animate them.
  • Renesis Player for Internet Explorer from examotion GmbH, supports SVG 1.1 on IE 6 and 7 (discontinued)<ref>Template:Cite web</ref>
  • SVG Web<ref name="svgweb">Template:Cite web</ref> is a JavaScript library for Web developers, targeted at Internet Explorer and dependent on the presence of an installed Adobe Flash plugin on the client machine. SVG Web provides partial support for SVG 1.1, SVG Animation (SMIL), Fonts, Video and Audio, DOM and style scripting.<ref name="C4Wauto-5839320">Template:Cite web</ref>

On 5 January 2010, a senior manager of the Internet Explorer team at Microsoft announced on his official blog that Microsoft had just requested to join the SVG Working Group of the W3C in order to "take part in ensuring future versions of the SVG spec will meet the needs of developers and end users," although no plans for SVG support in Internet Explorer were mentioned at that time.<ref name="C4Wauto-6837088">Template:Cite web</ref> Internet Explorer 9 beta supported a basic SVG feature set based on the SVG 1.1 W3C recommendation. Functionality has been implemented for most of the SVG document structure, interactivity through scripting and styling inline and through CSS. The presentation elements, attributes and DOM interfaces that have been implemented include basic shapes, colors, filling, gradients, patterns, paths and text.<ref name="IE9beta">Template:Cite web</ref>

Mobile support

SVG Tiny (SVGT) 1.1 and 1.2 are mobile profiles for SVG. SVGT 1.2 includes some features not found in SVG 1.1, including non-scaling strokes, which are supported by some SVG 1.1 implementations, such as Opera, Firefox and WebKit. As shared code bases between desktop and mobile browsers increased, the use of SVG 1.1 over SVGT 1.2 also increased.

Support for SVG may be limited to SVGT on older or more limited smart phones, or may be primarily limited by their respective operating system. Adobe Flash Lite has optionally supported SVG Tiny since version 1.1. At the SVG Open 2005 conference, Sun demonstrated a mobile implementation of SVG Tiny 1.1 for the Connected Limited Device Configuration (CLDC) platform.<ref>Template:Cite web</ref>

Mobiles that use Opera Mobile, as well as the iPhone's built in browser, also include SVG support. However, even though it used the WebKit engine, the Android built-in browser did not support SVG prior to v3.0 (Honeycomb).<ref>Template:Cite web</ref> Prior to v3.0, Firefox Mobile 4.0b2 (beta) for Android was the first browser running under Android to support SVG by default.<ref>Template:Cite web</ref>

The level of SVG Tiny support available varies from mobile to mobile, depending on the SVG engine installed. Many newer mobile products support additional features beyond SVG Tiny 1.1, like gradient and opacity; this is sometimes referred as "SVGT 1.1+", though there is no such standard.

Rim's BlackBerry has built-in support for SVG Tiny 1.1 since version 5.0.<ref>Template:Cite web</ref> Support continues for WebKit-based BlackBerry Torch browser in OS 6 and 7.<ref>Template:Cite web</ref>

Nokia's S60 platform has built-in support for SVG. For example, icons are generally rendered using the platform's SVG engine. Nokia has also led the JSR 226: Scalable 2D Vector Graphics API expert group that defines Java ME API for SVG presentation and manipulation. This API has been implemented in S60 Platform 3rd Edition Feature Pack 1 and onward.<ref>Template:Cite web</ref> Some Series 40 phones also support SVG (such as Nokia 6280).

Most Sony Ericsson phones beginning with K700 (by release date) support SVG Tiny 1.1. Phones beginning with K750 also support such features as opacity and gradients. Phones with Sony Ericsson Java Platform-8 have support for JSR 226.

Windows Phone has supported SVG since version 7.5

SVG is also supported on various mobile devices from Motorola, Samsung, LG, and Siemens mobile/BenQ-Siemens. eSVG, an SVG rendering library mainly written for embedded devices, is available on some mobile platforms.<ref>Template:Cite web</ref><ref>Template:Cite web</ref>

OpenVG is an API designed for hardware-accelerated 2D vector graphics. Its primary platforms are handheld devices, mobile phones, gaming or media consoles, and consumer electronic devices including operating systems with Gallium3D based graphics drivers.

Online SVG converters

This is an incomplete list of web applications that can convert SVG files to raster image formats (this process is known as rasterization), or raster images to SVG (this process is known as image tracing or vectorization) - without the need of installing a desktop software or browser plug-in.

  • Autotracer.org.<ref>Template:Cite web</ref> Online raster image vectorizer using the AutoTrace library. BMP, GIF, JPEG, or PNG to DXF, EPS, PDF, or SVG. Upload limit: 1MB.
  • FileFormat.info <ref>FileFormat.info - SVG to raster image conversion</ref> - Converts SVG to PNG, JPEG, TIFF. Output resolution can be specified. No batch processing. Upload limit: 5MB.
  • Online-Convert <ref>Template:Cite web</ref> - Converts to/from BMP, EPS, GIF, HDR, ICO, JPEG, PNG, SVG, TGA, TIFF, WBMP, WebP. No batch processing. The output (e. g. image size) is customizable; the conversion to SVG is handled by Potrace.<ref name="selinger">Template:Cite web</ref>
  • SVGConv <ref>Template:Cite web</ref> - Converts SVG to JPEG, PNG, GIF, BMP, TGA, TIFF, PDF, PS, EPS. Allows the user to customize the output (like image size, background color) and has batch processing features (converting multiple files in a single step). Upload limit: 10MB
  • SVG2Android <ref>Template:Cite web</ref> - Converts SVG to an Android VectorDrawable (introduced in API 21)

Application support

SVG images can be produced by the use of a vector graphics editor, such as Inkscape, Adobe Illustrator, or CorelDRAW, and rendered to common raster image formats such as PNG using the same software. Inkscape uses a (built-in) potrace to import raster image formats.<ref name="selinger" /><ref>Template:Cite web</ref>

Software can be programmed to render SVG images by using a library such as librsvg used by GNOME since 2000, or Batik. SVG images can also be rendered to any desired popular image format by using the free software command-line utility ImageMagick (which also uses librsvg under the hood).

Other uses for SVG include embedding for use in word processing (e.g. with LibreOffice) and desktop publishing (e.g. Scribus), plotting graphs (e.g. gnuplot), and importing paths (e.g. for use in GIMP or Blender). The Uniform Type Identifier for SVG used by Apple is public.svg-image and conforms to public.image and public.xml.

See also

Template:SVGSeries

References

1 }}
     | references-column-width 
     | references-column-count references-column-count-{{#if:1|30em}} }}
   | {{#if: 
     | references-column-width }} }}" style="{{#if: 30em
   | {{#iferror: {{#ifexpr: 30em > 1 }}
     | Template:Column-width
     | Template:Column-count }}
   | {{#if: 
     | Template:Column-width }} }} list-style-type: {{#switch: 
   | upper-alpha
   | upper-roman
   | lower-alpha
   | lower-greek
   | lower-roman = {{{group}}}
   | #default = decimal}};">
<references group=""></references>

External links

Template:Commons category Template:Wikibooks

Template:W3C Standards Template:Vector graphics markup languages Template:Graphics file formats Template:SVG Plugins Template:Web interfaces Template:Web browsers