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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user