Merge pull request #4537 from tk0miya/2852_imgconverter_gif_to_png

Fix #2852: imgconverter: Support to convert GIF to PNG
This commit is contained in:
Takeshi KOMIYA 2018-02-03 17:26:18 +09:00 committed by GitHub
commit eae54ef564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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])