image quality can be set in config file

(cherry-picked from
 https://gitorious.org/~dunkyp/mediagoblin/dunkyps-mediagoblin/commits/image_quality)
This commit is contained in:
dunkyp 2013-04-20 10:50:51 -05:00 committed by Christopher Allan Webber
parent 12dccc4552
commit 35f6d6a750
2 changed files with 6 additions and 3 deletions

View File

@ -91,6 +91,8 @@ max_height = integer(default=180)
[media_type:mediagoblin.media_types.image]
# One of BICUBIC, BILINEAR, NEAREST, ANTIALIAS
resize_filter = string(default="ANTIALIAS")
#level of compression used when resizing images
quality = integer(default=75)
[media_type:mediagoblin.media_types.video]
# Should we keep the original file?
@ -113,7 +115,6 @@ video_codecs = string_list(default=list("VP8 video"))
audio_codecs = string_list(default=list("Vorbis"))
dimensions_match = boolean(default=True)
[media_type:mediagoblin.media_types.audio]
keep_original = boolean(default=True)
# vorbisenc quality
@ -121,13 +122,13 @@ quality = float(default=0.3)
create_spectrogram = boolean(default=True)
spectrogram_fft_size = integer(default=4096)
[media_type:mediagoblin.media_types.ascii]
thumbnail_font = string(default=None)
[media_type:mediagoblin.media_types.pdf]
pdf_js = boolean(default=False)
[celery]
# default result stuff
CELERY_RESULT_BACKEND = string(default="database")

View File

@ -72,7 +72,9 @@ 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)
resized.save(resized_file,
quality=mgg.global_config['media_type:mediagoblin.media_types.image']\
['quality'])
mgg.public_store.copy_local_to_storage(tmp_resized_filename, new_path)