Add the possibility to disable image resizing (ref #34).

If the `img_processor` setting is `None`, image are not resized.
This commit is contained in:
Simon Conseil
2013-09-06 00:22:36 +02:00
parent 2e266ee6bd
commit a2ba01a103
3 changed files with 14 additions and 10 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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