resize_image: Refactor config loading a small bit.

Well, get the config into a local variable, for easier access.
This commit is contained in:
Elrond 2013-04-21 11:42:58 +02:00
parent fd1202b774
commit dc1ec36eb9

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