Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions optimize_images/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
pelican.
1 change: 1 addition & 0 deletions optimize_images/optimize_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', ''),
}
Expand Down
8 changes: 6 additions & 2 deletions org_reader/org_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down