source: frontend/node_modules/svgo/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 12.9 KB
Line 
1**english** | [русский](https://github.com/svg/svgo/blob/master/README.ru.md)
2- - -
3
4<img src="https://svg.github.io/svgo-logo.svg" width="200" height="200" alt="logo"/>
5
6## SVGO [![NPM version](https://badge.fury.io/js/svgo.svg)](https://npmjs.org/package/svgo) [![Build Status](https://secure.travis-ci.org/svg/svgo.svg)](https://travis-ci.org/svg/svgo) [![Coverage Status](https://img.shields.io/coveralls/svg/svgo.svg)](https://coveralls.io/r/svg/svgo?branch=master)
7
8**SVG O**ptimizer is a Nodejs-based tool for optimizing SVG vector graphics files.
9![](https://mc.yandex.ru/watch/18431326)
10
11## Why?
12
13SVG files, especially those exported from various editors, usually contain a lot of redundant and useless information. This can include editor metadata, comments, hidden elements, default or non-optimal values and other stuff that can be safely removed or converted without affecting the SVG rendering result.
14
15## What it can do
16
17SVGO has a plugin-based architecture, so almost every optimization is a separate plugin.
18
19Today we have:
20
21| Plugin | Description | Default |
22| ------ | ----------- | ------- |
23| [cleanupAttrs](https://github.com/svg/svgo/blob/master/plugins/cleanupAttrs.js) | cleanup attributes from newlines, trailing, and repeating spaces | `enabled` |
24| [inlineStyles](https://github.com/svg/svgo/blob/master/plugins/inlineStyles.js) | move and merge styles from `<style>` elements to element `style` attributes | `enabled` |
25| [removeDoctype](https://github.com/svg/svgo/blob/master/plugins/removeDoctype.js) | remove doctype declaration | `enabled` |
26| [removeXMLProcInst](https://github.com/svg/svgo/blob/master/plugins/removeXMLProcInst.js) | remove XML processing instructions | `enabled` |
27| [removeComments](https://github.com/svg/svgo/blob/master/plugins/removeComments.js) | remove comments | `enabled` |
28| [removeMetadata](https://github.com/svg/svgo/blob/master/plugins/removeMetadata.js) | remove `<metadata>` | `enabled` |
29| [removeTitle](https://github.com/svg/svgo/blob/master/plugins/removeTitle.js) | remove `<title>` | `enabled` |
30| [removeDesc](https://github.com/svg/svgo/blob/master/plugins/removeDesc.js) | remove `<desc>` | `enabled` |
31| [removeUselessDefs](https://github.com/svg/svgo/blob/master/plugins/removeUselessDefs.js) | remove elements of `<defs>` without `id` | `enabled` |
32| [removeXMLNS](https://github.com/svg/svgo/blob/master/plugins/removeXMLNS.js) | removes `xmlns` attribute (for inline svg) | `disabled` |
33| [removeEditorsNSData](https://github.com/svg/svgo/blob/master/plugins/removeEditorsNSData.js) | remove editors namespaces, elements, and attributes | `enabled` |
34| [removeEmptyAttrs](https://github.com/svg/svgo/blob/master/plugins/removeEmptyAttrs.js) | remove empty attributes | `enabled` |
35| [removeHiddenElems](https://github.com/svg/svgo/blob/master/plugins/removeHiddenElems.js) | remove hidden elements | `enabled` |
36| [removeEmptyText](https://github.com/svg/svgo/blob/master/plugins/removeEmptyText.js) | remove empty Text elements | `enabled` |
37| [removeEmptyContainers](https://github.com/svg/svgo/blob/master/plugins/removeEmptyContainers.js) | remove empty Container elements | `enabled` |
38| [removeViewBox](https://github.com/svg/svgo/blob/master/plugins/removeViewBox.js) | remove `viewBox` attribute when possible | `enabled` |
39| [cleanupEnableBackground](https://github.com/svg/svgo/blob/master/plugins/cleanupEnableBackground.js) | remove or cleanup `enable-background` attribute when possible | `enabled` |
40| [minifyStyles](https://github.com/svg/svgo/blob/master/plugins/minifyStyles.js) | minify `<style>` elements content with [CSSO](https://github.com/css/csso) | `enabled` |
41| [convertStyleToAttrs](https://github.com/svg/svgo/blob/master/plugins/convertStyleToAttrs.js) | convert styles into attributes | `enabled` |
42| [convertColors](https://github.com/svg/svgo/blob/master/plugins/convertColors.js) | convert colors (from `rgb()` to `#rrggbb`, from `#rrggbb` to `#rgb`) | `enabled` |
43| [convertPathData](https://github.com/svg/svgo/blob/master/plugins/convertPathData.js) | convert Path data to relative or absolute (whichever is shorter), convert one segment to another, trim useless delimiters, smart rounding, and much more | `enabled` |
44| [convertTransform](https://github.com/svg/svgo/blob/master/plugins/convertTransform.js) | collapse multiple transforms into one, convert matrices to the short aliases, and much more | `enabled` |
45| [removeUnknownsAndDefaults](https://github.com/svg/svgo/blob/master/plugins/removeUnknownsAndDefaults.js) | remove unknown elements content and attributes, remove attrs with default values | `enabled` |
46| [removeNonInheritableGroupAttrs](https://github.com/svg/svgo/blob/master/plugins/removeNonInheritableGroupAttrs.js) | remove non-inheritable group's "presentation" attributes | `enabled` |
47| [removeUselessStrokeAndFill](https://github.com/svg/svgo/blob/master/plugins/removeUselessStrokeAndFill.js) | remove useless `stroke` and `fill` attrs | `enabled` |
48| [removeUnusedNS](https://github.com/svg/svgo/blob/master/plugins/removeUnusedNS.js) | remove unused namespaces declaration | `enabled` |
49| [prefixIds](https://github.com/svg/svgo/blob/master/plugins/prefixIds.js) | prefix IDs and classes with the SVG filename or an arbitrary string | `disabled` |
50| [cleanupIDs](https://github.com/svg/svgo/blob/master/plugins/cleanupIDs.js) | remove unused and minify used IDs | `enabled` |
51| [cleanupNumericValues](https://github.com/svg/svgo/blob/master/plugins/cleanupNumericValues.js) | round numeric values to the fixed precision, remove default `px` units | `enabled` |
52| [cleanupListOfValues](https://github.com/svg/svgo/blob/master/plugins/cleanupListOfValues.js) | round numeric values in attributes that take a list of numbers (like `viewBox` or `enable-background`) | `disabled` |
53| [moveElemsAttrsToGroup](https://github.com/svg/svgo/blob/master/plugins/moveElemsAttrsToGroup.js) | move elements' attributes to their enclosing group | `enabled` |
54| [moveGroupAttrsToElems](https://github.com/svg/svgo/blob/master/plugins/moveGroupAttrsToElems.js) | move some group attributes to the contained elements | `enabled` |
55| [collapseGroups](https://github.com/svg/svgo/blob/master/plugins/collapseGroups.js) | collapse useless groups | `enabled` |
56| [removeRasterImages](https://github.com/svg/svgo/blob/master/plugins/removeRasterImages.js) | remove raster images | `disabled` |
57| [mergePaths](https://github.com/svg/svgo/blob/master/plugins/mergePaths.js) | merge multiple Paths into one | `enabled` |
58| [convertShapeToPath](https://github.com/svg/svgo/blob/master/plugins/convertShapeToPath.js) | convert some basic shapes to `<path>` | `enabled` |
59| [convertEllipseToCircle](https://github.com/svg/svgo/blob/master/plugins/convertEllipseToCircle.js) | convert non-eccentric `<ellipse>` to `<circle>` | `enabled` |
60| [sortAttrs](https://github.com/svg/svgo/blob/master/plugins/sortAttrs.js) | sort element attributes for epic readability | `disabled` |
61| [sortDefsChildren](https://github.com/svg/svgo/blob/master/plugins/sortDefsChildren.js) | sort children of `<defs>` in order to improve compression | `enabled` |
62| [removeDimensions](https://github.com/svg/svgo/blob/master/plugins/removeDimensions.js) | remove `width`/`height` and add `viewBox` if it's missing (opposite to removeViewBox, disable it first) | `disabled` |
63| [removeAttrs](https://github.com/svg/svgo/blob/master/plugins/removeAttrs.js) | remove attributes by pattern | `disabled` |
64| [removeAttributesBySelector](https://github.com/svg/svgo/blob/master/plugins/removeAttributesBySelector.js) | removes attributes of elements that match a css selector | `disabled` |
65| [removeElementsByAttr](https://github.com/svg/svgo/blob/master/plugins/removeElementsByAttr.js) | remove arbitrary elements by ID or className | `disabled` |
66| [addClassesToSVGElement](https://github.com/svg/svgo/blob/master/plugins/addClassesToSVGElement.js) | add classnames to an outer `<svg>` element | `disabled` |
67| [addAttributesToSVGElement](https://github.com/svg/svgo/blob/master/plugins/addAttributesToSVGElement.js) | adds attributes to an outer `<svg>` element | `disabled` |
68| [removeOffCanvasPaths](https://github.com/svg/svgo/blob/master/plugins/removeOffCanvasPaths.js) | removes elements that are drawn outside of the viewbox | `disabled` |
69| [removeStyleElement](https://github.com/svg/svgo/blob/master/plugins/removeStyleElement.js) | remove `<style>` elements | `disabled` |
70| [removeScriptElement](https://github.com/svg/svgo/blob/master/plugins/removeScriptElement.js) | remove `<script>` elements | `disabled` |
71| [reusePaths](https://github.com/svg/svgo/blob/master/plugins/reusePaths.js) | Find duplicated <path> elements and replace them with <use> links | `disabled` |
72
73Want to know how it works and how to write your own plugin? [Of course you want to](https://github.com/svg/svgo/blob/master/docs/how-it-works/en.md). ([동작방법](https://github.com/svg/svgo/blob/master/docs/how-it-works/ko.md))
74
75
76## Installation
77
78```sh
79$ [sudo] npm install -g svgo
80```
81
82## Usage
83
84### <abbr title="Command Line Interface">CLI</abbr>
85
86```
87Usage:
88 svgo [OPTIONS] [ARGS]
89
90Options:
91 -h, --help : Help
92 -v, --version : Version
93 -i INPUT, --input=INPUT : Input file, "-" for STDIN
94 -s STRING, --string=STRING : Input SVG data string
95 -f FOLDER, --folder=FOLDER : Input folder, optimize and rewrite all *.svg files
96 -o OUTPUT, --output=OUTPUT : Output file or folder (by default the same as the input), "-" for STDOUT
97 -p PRECISION, --precision=PRECISION : Set number of digits in the fractional part, overrides plugins params
98 --config=CONFIG : Config file or JSON string to extend or replace default
99 --disable=PLUGIN : Disable plugin by name, "--disable=PLUGIN1,PLUGIN2" for multiple plugins
100 --enable=PLUGIN : Enable plugin by name, "--enable=PLUGIN3,PLUGIN4" for multiple plugins
101 --datauri=DATAURI : Output as Data URI string (base64, URI encoded or unencoded)
102 --multipass : Pass over SVGs multiple times to ensure all optimizations are applied
103 --pretty : Make SVG pretty printed
104 --indent=INDENT : Indent number when pretty printing SVGs
105 -r, --recursive : Use with '-f'. Optimizes *.svg files in folders recursively.
106 -q, --quiet : Only output error messages, not regular status messages
107 --show-plugins : Show available plugins and exit
108
109Arguments:
110 INPUT : Alias to --input
111```
112
113* with files:
114
115 ```sh
116 $ svgo test.svg
117 ```
118
119 or:
120
121 ```sh
122 $ svgo *.svg
123 ```
124
125 ```sh
126 $ svgo test.svg -o test.min.svg
127 ```
128
129 ```sh
130 $ svgo test.svg other.svg third.svg
131 ```
132
133 ```sh
134 $ svgo test.svg other.svg third.svg -o test.min.svg -o other.min.svg -o third.min.svg
135 ```
136
137* with STDIN / STDOUT:
138
139 ```sh
140 $ cat test.svg | svgo -i - -o - > test.min.svg
141 ```
142
143* with folder
144
145 ```sh
146 $ svgo -f ../path/to/folder/with/svg/files
147 ```
148
149 or:
150
151 ```sh
152 $ svgo -f ../path/to/folder/with/svg/files -o ../path/to/folder/with/svg/output
153 ```
154
155 ```sh
156 $ svgo *.svg -o ../path/to/folder/with/svg/output
157 ```
158
159* with strings:
160
161 ```sh
162 $ svgo -s '<svg version="1.1">test</svg>' -o test.min.svg
163 ```
164
165 or even with Data URI base64:
166
167 ```sh
168 $ svgo -s 'data:image/svg+xml;base64,...' -o test.min.svg
169 ```
170
171* with SVGZ:
172
173 from `.svgz` to `.svg`:
174
175 ```sh
176 $ gunzip -c test.svgz | svgo -i - -o test.min.svg
177 ```
178
179 from `.svg` to `.svgz`:
180
181 ```sh
182 $ svgo test.svg -o - | gzip -cfq9 > test.svgz
183 ```
184
185### Other Ways to Use SVGO
186
187* as a web app – [SVGOMG](https://jakearchibald.github.io/svgomg/)
188* as a Nodejs module – [examples](https://github.com/svg/svgo/tree/master/examples)
189* as a Grunt task – [grunt-svgmin](https://github.com/sindresorhus/grunt-svgmin)
190* as a Gulp task – [gulp-svgmin](https://github.com/ben-eb/gulp-svgmin)
191* as a Mimosa module – [mimosa-minify-svg](https://github.com/dbashford/mimosa-minify-svg)
192* as an OSX Folder Action – [svgo-osx-folder-action](https://github.com/svg/svgo-osx-folder-action)
193* as a webpack loader – [image-webpack-loader](https://github.com/tcoopman/image-webpack-loader)
194* as a Telegram Bot – [svgo_bot](https://github.com/maksugr/svgo_bot)
195* as a PostCSS plugin – [postcss-svgo](https://github.com/ben-eb/postcss-svgo)
196* as an Inkscape plugin – [inkscape-svgo](https://github.com/konsumer/inkscape-svgo)
197* as a Sketch plugin - [svgo-compressor](https://github.com/BohemianCoding/svgo-compressor)
198* as macOS app - [Image Shrinker](https://image-shrinker.com)
199* as a Rollup plugin - [rollup-plugin-svgo](https://github.com/porsager/rollup-plugin-svgo)
200
201## Backers
202
203| [<img src="https://sheetjs.com/sketch128.png" width="80">](https://sheetjs.com/) | [<img src="https://rawgithub.com/fontello/fontello/master/fontello-image.svg" width="80">](http://fontello.com/) |
204|:-:|:-:|
205| [SheetJS LLC](https://sheetjs.com/) | [Fontello](http://fontello.com/) |
206
207## Donations
208
209- PayPal: https://www.paypal.me/deepsweet
210
211## License and Copyright
212
213This software is released under the terms of the [MIT license](https://github.com/svg/svgo/blob/master/LICENSE).
214
215Logo by [Yegor Bolshakov](http://xizzzy.ru/).
Note: See TracBrowser for help on using the repository browser.