You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2019/12/12 22:36:21 UTC
[allura] 01/01: [#8343] compress images thumbnails better than
default
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8343
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 459671d2f7ee16c0bf5337784c8a0460028af8da
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Thu Dec 12 17:36:12 2019 -0500
[#8343] compress images thumbnails better than default
---
Allura/allura/model/filesystem.py | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/Allura/allura/model/filesystem.py b/Allura/allura/model/filesystem.py
index 325ec40..523904c 100644
--- a/Allura/allura/model/filesystem.py
+++ b/Allura/allura/model/filesystem.py
@@ -156,11 +156,10 @@ class File(MappedClass):
if format == 'BMP': # use jpg format if bmp is provided
format = 'PNG'
with thumbnail.wfile() as fp_w:
+ save_kwargs = {}
if 'transparency' in image.info:
- image.save(fp_w,
- format, transparency=image.info['transparency'])
- else:
- image.save(fp_w, format)
+ save_kwargs['transparency'] = image.info['transparency']
+ image.save(fp_w, format, optimize=True, **save_kwargs)
return thumbnail
@@ -203,11 +202,10 @@ class File(MappedClass):
filename=filename, content_type=content_type, **original_meta)
with original.wfile() as fp_w:
try:
+ save_kwargs = {}
if 'transparency' in image.info:
- image.save(fp_w,
- format, transparency=image.info['transparency'], save_all=save_anim)
- else:
- image.save(fp_w, format, save_all=save_anim)
+ save_kwargs['transparency'] = image.info['transparency']
+ image.save(fp_w, format, save_all=save_anim, optimize=True, **save_kwargs)
except Exception as e:
session(original).expunge(original)
log.error('Error saving image %s %s', filename, e)