EN
Bash - compress svg file
4
points
In this short article we want to show how to reduce *.svg file size using svgo command (SVG Optimizer) in Bash or Windows Command Prompt. Motivation to optimize svg files is web development where we need to provide small file sizes to speed up page loading.
Quick solution (use the following command):
svgo image.svg
Output:
image.svg:
Done in 60 ms!
6.365 KiB - 25% = 4.771 KiB
Where:
25%indicates how much file size was reduced,6.365 KiBis file size before optimization,4.771 KiBis file size after optimization.
Note: by default
svgooverwrites exiting file with optimal version.
svgo instalation
To install svgo it is necessary to do few steps:
- be sure that NodeJS is installed (instalation instruction for Windows is avaialble here),
- install
svgousing the following command:npm install -g svgo - now we can use
svgocommand (go back to Quick solution).