@emasoft/svg-matrix 1.0.24 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -3
- package/package.json +1 -1
- package/src/index.js +2 -2
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
<p align="center">
|
|
13
13
|
<a href="#part-1-core-math-library">Core Math</a> •
|
|
14
14
|
<a href="#part-2-svg-toolbox">SVG Toolbox</a> •
|
|
15
|
+
<a href="#svgm---svgo-compatible-optimizer-drop-in-replacement">svgm (SVGO replacement)</a> •
|
|
15
16
|
<a href="#installation">Install</a> •
|
|
16
17
|
<a href="API.md">API Reference</a>
|
|
17
18
|
</p>
|
|
@@ -185,14 +186,17 @@ SVG files are pictures made of shapes, paths, and effects. This toolbox can:
|
|
|
185
186
|
|
|
186
187
|
### Why Use This Instead of SVGO?
|
|
187
188
|
|
|
188
|
-
| | SVGO |
|
|
189
|
+
| | SVGO | svgm (this package) |
|
|
189
190
|
|--|------|-----------|
|
|
190
191
|
| **Math precision** | 15 digits (can accumulate errors) | 80 digits (no errors) |
|
|
191
192
|
| **Verification** | None (hope it works) | Mathematical proof each step is correct |
|
|
192
193
|
| **Attribute handling** | May lose clip-path, mask, filter | Guarantees ALL attributes preserved |
|
|
194
|
+
| **CLI syntax** | `svgo input.svg -o out.svg` | `svgm input.svg -o out.svg` (identical!) |
|
|
193
195
|
| **Use case** | Quick file size reduction | Precision-critical applications |
|
|
194
196
|
|
|
195
|
-
**
|
|
197
|
+
**Drop-in replacement:** The `svgm` command uses the exact same syntax as SVGO. Just replace `svgo` with `svgm` in your scripts.
|
|
198
|
+
|
|
199
|
+
**Use svgm/svg-matrix when:** CAD, GIS, scientific visualization, animation, or when visual correctness matters.
|
|
196
200
|
|
|
197
201
|
**Use SVGO when:** Quick optimization where small rounding errors are acceptable.
|
|
198
202
|
|
|
@@ -200,7 +204,62 @@ SVG files are pictures made of shapes, paths, and effects. This toolbox can:
|
|
|
200
204
|
|
|
201
205
|
## Command Line Tools
|
|
202
206
|
|
|
203
|
-
### `
|
|
207
|
+
### `svgm` - SVGO-Compatible Optimizer (Drop-in Replacement)
|
|
208
|
+
|
|
209
|
+
A drop-in replacement for SVGO with identical syntax. Simply replace `svgo` with `svgm`:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Basic optimization (same as SVGO)
|
|
213
|
+
svgm input.svg -o output.svg
|
|
214
|
+
|
|
215
|
+
# Optimize folder recursively
|
|
216
|
+
svgm -f ./icons/ -o ./optimized/ -r
|
|
217
|
+
|
|
218
|
+
# Multiple passes for maximum compression
|
|
219
|
+
svgm --multipass input.svg -o output.svg
|
|
220
|
+
|
|
221
|
+
# Pretty print output
|
|
222
|
+
svgm --pretty --indent 2 input.svg -o output.svg
|
|
223
|
+
|
|
224
|
+
# Set precision
|
|
225
|
+
svgm -p 2 input.svg -o output.svg
|
|
226
|
+
|
|
227
|
+
# Show available optimizations
|
|
228
|
+
svgm --show-plugins
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Options (SVGO-compatible):**
|
|
232
|
+
|
|
233
|
+
| Option | What It Does |
|
|
234
|
+
|--------|--------------|
|
|
235
|
+
| `-o <file>` | Output file or folder |
|
|
236
|
+
| `-f <folder>` | Input folder (batch mode) |
|
|
237
|
+
| `-r, --recursive` | Process folders recursively |
|
|
238
|
+
| `-p <n>` | Decimal precision |
|
|
239
|
+
| `--multipass` | Multiple optimization passes |
|
|
240
|
+
| `--pretty` | Pretty print output |
|
|
241
|
+
| `--indent <n>` | Indentation for pretty print |
|
|
242
|
+
| `-q, --quiet` | Suppress output |
|
|
243
|
+
| `--datauri <type>` | Output as data URI (base64, enc, unenc) |
|
|
244
|
+
| `--show-plugins` | List available optimizations |
|
|
245
|
+
|
|
246
|
+
**Default optimizations (matching SVGO preset-default):**
|
|
247
|
+
|
|
248
|
+
- Remove DOCTYPE, XML processing instructions, comments, metadata
|
|
249
|
+
- Remove editor namespaces (Inkscape, Illustrator, etc.)
|
|
250
|
+
- Cleanup IDs, attributes, numeric values
|
|
251
|
+
- Convert colors to shorter forms
|
|
252
|
+
- Collapse groups, merge paths
|
|
253
|
+
- Sort attributes for better gzip compression
|
|
254
|
+
- And 20+ more optimizations
|
|
255
|
+
|
|
256
|
+
Run `svgm --help` for all options.
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
### `svg-matrix` - Advanced SVG Processing
|
|
261
|
+
|
|
262
|
+
For precision-critical operations beyond simple optimization:
|
|
204
263
|
|
|
205
264
|
```bash
|
|
206
265
|
# Flatten all transforms into coordinates
|
|
@@ -232,6 +291,8 @@ svg-matrix info input.svg
|
|
|
232
291
|
|
|
233
292
|
Run `svg-matrix --help` for all options.
|
|
234
293
|
|
|
294
|
+
---
|
|
295
|
+
|
|
235
296
|
### `svglinter` - Find problems in SVG files
|
|
236
297
|
|
|
237
298
|
```bash
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* SVG path conversion, and 2D/3D affine transformations using Decimal.js.
|
|
6
6
|
*
|
|
7
7
|
* @module @emasoft/svg-matrix
|
|
8
|
-
* @version 1.0.
|
|
8
|
+
* @version 1.0.25
|
|
9
9
|
* @license MIT
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
@@ -86,7 +86,7 @@ Decimal.set({ precision: 80 });
|
|
|
86
86
|
* Library version
|
|
87
87
|
* @constant {string}
|
|
88
88
|
*/
|
|
89
|
-
export const VERSION = '1.0.
|
|
89
|
+
export const VERSION = '1.0.25';
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Default precision for path output (decimal places)
|