diff --git a/CHANGES b/CHANGES index 292313f28..32f47789a 100644 --- a/CHANGES +++ b/CHANGES @@ -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 ---------- diff --git a/sphinx/ext/imgconverter.py b/sphinx/ext/imgconverter.py index 95f579e36..8546593a7 100644 --- a/sphinx/ext/imgconverter.py +++ b/sphinx/ext/imgconverter.py @@ -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])