From a2ba01a103cc19ff4a0513b2ddb2f6488e62301b Mon Sep 17 00:00:00 2001 From: Simon Conseil Date: Fri, 6 Sep 2013 00:22:36 +0200 Subject: [PATCH] Add the possibility to disable image resizing (ref #34). If the `img_processor` setting is `None`, image are not resized. --- sigal/image.py | 20 ++++++++++---------- sigal/settings.py | 3 +++ sigal/templates/sigal.conf.py | 1 + 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/sigal/image.py b/sigal/image.py index 41e4519..44c59d9 100644 --- a/sigal/image.py +++ b/sigal/image.py @@ -69,17 +69,17 @@ def generate_image(source, outname, settings, options=None): pass # Resize the image - method = settings['img_processor'] + if settings['img_processor']: + try: + logger.debug('Processor: %s', settings['img_processor']) + processor_cls = getattr(pilkit.processors, + settings['img_processor']) + except AttributeError: + logger.error('Wrong processor name: %s', settings['img_processor']) + sys.exit() - try: - logger.debug('Processor: %s', method) - processor_cls = getattr(pilkit.processors, method) - except AttributeError: - logger.error('Wrong processor name: %s', method) - sys.exit() - - processor = processor_cls(*settings['img_size'], upscale=False) - img = processor.process(img) + processor = processor_cls(*settings['img_size'], upscale=False) + img = processor.process(img) # Adjust the image after resizing img = Adjust(**settings['adjust_options']).process(img) diff --git a/sigal/settings.py b/sigal/settings.py index 913f177..32a18b8 100644 --- a/sigal/settings.py +++ b/sigal/settings.py @@ -120,6 +120,9 @@ def read_settings(filename=None): logger.warning("The %s setting should be specified with the " "largest value first.", key) + if not settings['img_processor']: + logger.info('No Processor, images will not be resized') + return settings diff --git a/sigal/templates/sigal.conf.py b/sigal/templates/sigal.conf.py index d214535..090ed4c 100644 --- a/sigal/templates/sigal.conf.py +++ b/sigal/templates/sigal.conf.py @@ -24,6 +24,7 @@ img_size = (800, 600) # - ResizeToFit: fit the image within the specified dimensions (default) # - ResizeToFill: crop THE IMAGE it to the exact specified width and height # - SmartResize: identical to ResizeToFill, but uses entropy to crop the image +# - None: don't resize # img_processor = 'ResizeToFit' # Adjust the image after resizing it. A default value of 1.0 leaves the images