From 9f80a33d9c6f7fffaf4de04212d2b35a4170ebc3 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Sun, 4 Aug 2013 14:41:39 +0200 Subject: [PATCH] Add adjust_options This gives the user the ability to process the images after resizing them. In particular, the color, contrast, brightness and sharpness can be adjusted. --- sigal/image.py | 3 +++ sigal/settings.py | 2 ++ sigal/templates/sigal.conf.py | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/sigal/image.py b/sigal/image.py index 8af08ee..f1e893e 100644 --- a/sigal/image.py +++ b/sigal/image.py @@ -72,6 +72,9 @@ def generate_image(source, outname, settings, options=None): processor = processor_cls(*settings['img_size'], upscale=False) img = processor.process(img) + # Adjust the image after resizing + img = Adjust(**settings['adjust_options']).process(img) + if settings['copyright']: add_copyright(img, settings['copyright']) diff --git a/sigal/settings.py b/sigal/settings.py index 1a19999..913f177 100644 --- a/sigal/settings.py +++ b/sigal/settings.py @@ -29,6 +29,8 @@ _DEFAULT_CONFIG = { 'destination': '_build', 'img_size': (640, 480), 'img_processor': 'ResizeToFit', + 'adjust_options': {'color': 1.0, 'brightness': 1.0, + 'contrast': 1.0, 'sharpness': 1.0}, 'make_thumbs': True, 'thumb_prefix': '', 'thumb_suffix': '', diff --git a/sigal/templates/sigal.conf.py b/sigal/templates/sigal.conf.py index ce2976c..d214535 100644 --- a/sigal/templates/sigal.conf.py +++ b/sigal/templates/sigal.conf.py @@ -26,6 +26,13 @@ img_size = (800, 600) # - SmartResize: identical to ResizeToFill, but uses entropy to crop the image # img_processor = 'ResizeToFit' +# Adjust the image after resizing it. A default value of 1.0 leaves the images +# untouched. +# adjust_options = {'color': 1.0, +# 'brightness': 1.0, +# 'contrast': 1.0, +# 'sharpness': 1.0} + # Generate thumbnails # make_thumbs = True