diff --git a/optimize_images/Readme.md b/optimize_images/Readme.md index d6fcc0ff0..501c68a02 100644 --- a/optimize_images/Readme.md +++ b/optimize_images/Readme.md @@ -2,11 +2,12 @@ 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. +effect on image quality. It uses [jpegtran][1], [OptiPNG][2] and [svgo][3]. +It assumes that all of these tools are installed on system path. [1]: http://jpegclub.org/jpegtran/ "jpegtran" [2]: http://optipng.sourceforge.net/ "OptiPNG" +[3]: https://github.com/svg/svgo "SVGO" Installation @@ -23,4 +24,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. \ No newline at end of file +pelican. diff --git a/optimize_images/optimize_images.py b/optimize_images/optimize_images.py index 308783703..33593ceed 100644 --- a/optimize_images/optimize_images.py +++ b/optimize_images/optimize_images.py @@ -22,6 +22,7 @@ # 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', ''), } diff --git a/org_reader/org_reader.py b/org_reader/org_reader.py index 22d306cb0..83efa2c49 100644 --- a/org_reader/org_reader.py +++ b/org_reader/org_reader.py @@ -84,9 +84,13 @@ def read(self, filename): cmd.append('--eval') cmd.append(self.ELISP_EXEC.format(filename, backend)) - LOG.debug("OrgReader: running command `{0}`".format(cmd)) + LOG.debug("OrgReader: running command `%s`" % (' '.join(cmd))) - json_result = subprocess.check_output(cmd, universal_newlines=True) + try: + json_result = subprocess.check_output(cmd, universal_newlines=True, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + print("Failed error: output %s" % e.output) + raise e json_output = json.loads(json_result) # get default slug from .org filename