From dc1ec36eb9a3bbe37a4dac2e94d4dae339ef0715 Mon Sep 17 00:00:00 2001 From: Elrond Date: Sun, 21 Apr 2013 11:42:58 +0200 Subject: [PATCH] resize_image: Refactor config loading a small bit. Well, get the config into a local variable, for easier access. --- mediagoblin/media_types/image/processing.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mediagoblin/media_types/image/processing.py b/mediagoblin/media_types/image/processing.py index b8d576e4..142ec2bf 100644 --- a/mediagoblin/media_types/image/processing.py +++ b/mediagoblin/media_types/image/processing.py @@ -50,16 +50,15 @@ def resize_image(entry, filename, new_path, exif_tags, workdir, new_size, workdir -- directory path for storing converted image files new_size -- 2-tuple size for the resized image """ + config = mgg.global_config['media_type:mediagoblin.media_types.image'] + try: resized = Image.open(filename) except IOError: raise BadMediaFail() resized = exif_fix_image_orientation(resized, exif_tags) # Fix orientation - filter_config = \ - mgg.global_config['media_type:mediagoblin.media_types.image']\ - ['resize_filter'] - + filter_config = config['resize_filter'] try: resize_filter = PIL_FILTERS[filter_config.upper()] except KeyError: @@ -72,9 +71,7 @@ def resize_image(entry, filename, new_path, exif_tags, workdir, new_size, # Copy the new file to the conversion subdir, then remotely. tmp_resized_filename = os.path.join(workdir, new_path[-1]) with file(tmp_resized_filename, 'w') as resized_file: - resized.save(resized_file, - quality=mgg.global_config['media_type:mediagoblin.media_types.image']\ - ['quality']) + resized.save(resized_file, quality=config['quality']) mgg.public_store.copy_local_to_storage(tmp_resized_filename, new_path) -- 2.25.1