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:20 UTC

[allura] branch db/8343 created (now 459671d)

This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a change to branch db/8343
in repository https://gitbox.apache.org/repos/asf/allura.git.


      at 459671d  [#8343] compress images thumbnails better than default

This branch includes the following new commits:

     new 459671d  [#8343] compress images thumbnails better than default

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[allura] 01/01: [#8343] compress images thumbnails better than default

Posted by br...@apache.org.
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)