resize_image: Refactor config loading a small bit.
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Sun, 21 Apr 2013 09:42:58 +0000 (11:42 +0200)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Sun, 21 Apr 2013 17:26:57 +0000 (19:26 +0200)
Well, get the config into a local variable, for easier access.

mediagoblin/media_types/image/processing.py

index b8d576e40af59dff3b731c0dfaf1d238fa7c84c0..142ec2bfb73474417d2268da7f3284ef64092e01 100644 (file)
@@ -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)