2

How can I simplify SVG files (all the paths inside it) using a Windows command line tool? It's important that it be fast because I should use it in production.
Adobe Illustrator has a good simplifier (Object->Path->Simplify) but can't be used as CLI. https://github.com/mourner/simplify-js is another good tool but it doesn't have a CLI.
Please comment below this question if you know any non CLI tool (in any languages including C++ and Python) that works directly with SVG files.

  • 1
    Your last sentence should be a separate question (Please don't ask two questions in one on SE sites). You can have both questions point to each other to emphasize that you want a CLI tool in one and a library in the other. – Jan Doggen Oct 29 '18 at 8:42
  • If you can code, it would be simple to write a script with AutoIt to automate Adobe Illustrator to do this for as many files as you like – Mawg Nov 29 '18 at 13:54
1

You could install node.js and use command line JavaScript along with SVG Optimizer (SVGO) for optimizing SVG vector graphics files.

  • 1
    I couldn't find any tools for simplifying SVG paths in SVGO. Are you sure it does that? – J. Mando Oct 29 '18 at 14:06
1

Scour is a python tool which removes redundant and spurious data from SVG files and then optimizes them.

Install

If you are on debian you can install it by typing this command:

sudo apt install scour

On most platforms you can install with:

pip install scour

If your current permissions are not sufficient you can either use:

pip install --user scour

or

sudo pip install scour

Usage

Standard:

scour -i input.svg -o output.svg

Better (for older versions of Internet Explorer):

scour -i input.svg -o output.svg --enable-viewboxing

Maximum scrubbing:

scour -i input.svg -o output.svg --enable-viewboxing --enable-id-stripping \
  --enable-comment-stripping --shorten-ids --indent=none

Maximum scrubbing and a compressed SVGZ file:

scour -i input.svg -o output.svgz --enable-viewboxing --enable-id-stripping \
  --enable-comment-stripping --shorten-ids --indent=none

Note that Scour is a python library that also provides a command line tool by utilizing entry points so will require a working python (2.7 or 3.4+ installation) - it is cross platform.

  • I couldn't find any tools for simplifying SVG paths in Scour. Are you sure it does that? – J. Mando Oct 29 '18 at 19:46
  • 1
    @J.Mando yes I am reasonably sure that it does optimize not quite the same as simplify svg files - depending on the origin of the file and the options selected the saving can be quite significant. – Steve Barnes Oct 30 '18 at 6:13
  • I'm not looking for optimization. Please read the question. – J. Mando Oct 30 '18 at 6:47
  • @J.Mando Please clarify what you mean by simplify most optimizations are also simplifications as a simpler SVG will download, load and render more quickly than a complex one and fast download, load & render is the goal of optimization - the only definition of simplification that I know of that is not also optimization is attempting to make things more human readable which may run counter to optimization. – Steve Barnes Oct 31 '18 at 6:01
  • I think the question is clear. I want path simplification. Just like the one in Adobe Illustrator - which I mentioned. – J. Mando Oct 31 '18 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.