Add image_converter_args confval

This commit is contained in:
Takeshi KOMIYA 2017-04-22 13:26:09 +09:00
parent c525723807
commit 2b9b4f92a5
2 changed files with 10 additions and 2 deletions

View File

@ -23,3 +23,8 @@ Configuration
A path to :command:`convert` command. By default, the imgconverter uses
the command from search paths.
.. confval:: image_converter_args
Additional command-line arguments to give to :command:`convert`, as a list.
The default is an empty list ``[]``.

View File

@ -51,8 +51,10 @@ class ImagemagickConverter(ImageConverter):
# type: (unicode, unicode) -> None
"""Converts the image to expected one."""
try:
p = subprocess.Popen([self.config.image_converter, _from, _to],
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
args = ([self.config.image_converter] +
self.config.image_converter_args +
[_from, _to])
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
except OSError as err:
if err.errno != ENOENT: # No such file or directory
raise
@ -80,6 +82,7 @@ def setup(app):
# type: (Sphinx) -> Dict[unicode, Any]
app.add_post_transform(ImagemagickConverter)
app.add_config_value('image_converter', 'convert', 'env')
app.add_config_value('image_converter_args', [], 'env')
return {
'version': 'builtin',