Fix #2852: imgconverter: Support to convert GIF to PNG

This commit is contained in:
Takeshi KOMIYA 2018-02-03 02:38:50 +09:00
parent 23796c35bf
commit d97468bd5d
2 changed files with 6 additions and 0 deletions

View File

@ -30,6 +30,7 @@ Features added
value
* :confval:`source_suffix` allows a mapping fileext to file types
* Add :confval:`author` as a configuration value
* #2852: imgconverter: Support to convert GIF to PNG
Bugs fixed
----------

View File

@ -28,6 +28,7 @@ logger = logging.getLogger(__name__)
class ImagemagickConverter(ImageConverter):
conversion_rules = [
('image/svg+xml', 'image/png'),
('image/gif', 'image/png'),
('application/pdf', 'image/png'),
]
@ -52,6 +53,10 @@ class ImagemagickConverter(ImageConverter):
# type: (unicode, unicode) -> bool
"""Converts the image to expected one."""
try:
if _from.lower().endswith('.gif'):
# when target is GIF format, pick the first frame
_from += '[0]'
args = ([self.config.image_converter] +
self.config.image_converter_args +
[_from, _to])