Преглед изворни кода

Merge pull request #998 from jappeace/svgo

Svgo support for svg compression
Justin Mayer пре 6 година
родитељ
комит
99116a5bc3
2 измењених фајлова са 9 додато и 6 уклоњено
  1. 8 6
      optimize_images/Readme.md
  2. 1 0
      optimize_images/optimize_images.py

+ 8 - 6
optimize_images/Readme.md

@@ -1,12 +1,14 @@
 Optimize Images Plugin For Pelican
 ==================================
 
-This plugin applies lossless compression on JPEG and PNG images, with no
-effect on image quality. It uses [jpegtran][1] and [OptiPNG][2]. It assumes
-that both of these tools are installed on system path.
+This plugin applies lossless compression on JPEG, PNG and SVG images, with no
+effect on image quality via [jpegtran][], [OptiPNG][] and [svgo][] respectively. 
+The plugin assumes that all of these tools are installed, with associated
+executables available on the system path.
 
-[1]: http://jpegclub.org/jpegtran/              "jpegtran"
-[2]: http://optipng.sourceforge.net/            "OptiPNG"
+[jpegtran]: http://jpegclub.org/jpegtran/
+[OptiPNG]: http://optipng.sourceforge.net/
+[SVGO]: https://github.com/svg/svgo
 
 
 Installation
@@ -23,4 +25,4 @@ Then use as follows by adding the following to your settings.py:
 Usage
 -----
 The plugin will activate and optimize images upon `finalized` signal of
-pelican.
+Pelican.

+ 1 - 0
optimize_images/optimize_images.py

@@ -22,6 +22,7 @@ SHOW_OUTPUT = logger.getEffectiveLevel() <= logging.DEBUG
 # A list of file types with their respective commands
 COMMANDS = {
     # '.ext': ('command {flags} {filename', 'silent_flag', 'verbose_flag')
+    '.svg': ('svgo {flags} --input="{filename}" --output="{filename}"', '--quiet', ''),
     '.jpg': ('jpegtran {flags} -copy none -optimize -outfile "{filename}" "{filename}"', '', '-v'),
     '.png': ('optipng {flags} "{filename}"', '--quiet', ''),
 }