Mercurial > libervia-backend
comparison sat/core/sat_main.py @ 3220:4fbea7f1e012
tools (images): methods renaming
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 22 Mar 2020 12:52:43 +0100 |
parents | ae09989e9feb |
children | 2f406b762788 |
comparison
equal
deleted
inserted
replaced
3219:2ba602aef90e | 3220:4fbea7f1e012 |
---|---|
1 #!/usr/bin/env python3 | 1 #!/usr/bin/env python3 |
2 | 2 |
3 # SAT: a jabber client | 3 # SàT: an XMPP client |
4 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org) | 4 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org) |
5 | 5 |
6 # This program is free software: you can redistribute it and/or modify | 6 # This program is free software: you can redistribute it and/or modify |
7 # it under the terms of the GNU Affero General Public License as published by | 7 # it under the terms of the GNU Affero General Public License as published by |
8 # the Free Software Foundation, either version 3 of the License, or | 8 # the Free Software Foundation, either version 3 of the License, or |
40 from sat.memory import memory | 40 from sat.memory import memory |
41 from sat.memory import cache | 41 from sat.memory import cache |
42 from sat.memory import encryption | 42 from sat.memory import encryption |
43 from sat.tools import async_trigger as trigger | 43 from sat.tools import async_trigger as trigger |
44 from sat.tools import utils | 44 from sat.tools import utils |
45 from sat.tools import images | 45 from sat.tools import image |
46 from sat.tools.common import dynamic_import | 46 from sat.tools.common import dynamic_import |
47 from sat.tools.common import regex | 47 from sat.tools.common import regex |
48 from sat.tools.common import data_format | 48 from sat.tools.common import data_format |
49 from sat.stdui import ui_contact_list, ui_profile_manager | 49 from sat.stdui import ui_contact_list, ui_profile_manager |
50 import sat.plugins | 50 import sat.plugins |
738 return ret_data | 738 return ret_data |
739 | 739 |
740 # images | 740 # images |
741 | 741 |
742 def _imageCheck(self, path): | 742 def _imageCheck(self, path): |
743 report = images.checkImage(self, path) | 743 report = image.check(self, path) |
744 return data_format.serialise(report) | 744 return data_format.serialise(report) |
745 | 745 |
746 def _imageResize(self, path, width, height): | 746 def _imageResize(self, path, width, height): |
747 d = images.resizeImage(path, (width, height)) | 747 d = image.resize(path, (width, height)) |
748 d.addCallback(lambda new_image_path: str(new_image_path)) | 748 d.addCallback(lambda new_image_path: str(new_image_path)) |
749 return d | 749 return d |
750 | 750 |
751 def _imageGeneratePreview(self, path, profile_key): | 751 def _imageGeneratePreview(self, path, profile_key): |
752 client = self.getClient(profile_key) | 752 client = self.getClient(profile_key) |
758 """Helper method to generate in cache a preview of an image | 758 """Helper method to generate in cache a preview of an image |
759 | 759 |
760 @param path(Path): path to the image | 760 @param path(Path): path to the image |
761 @return (Path): path to the generated preview | 761 @return (Path): path to the generated preview |
762 """ | 762 """ |
763 report = images.checkImage(self, path, max_size=(300, 300)) | 763 report = image.check(self, path, max_size=(300, 300)) |
764 | 764 |
765 if not report['too_large']: | 765 if not report['too_large']: |
766 # in the unlikely case that image is already smaller than a preview | 766 # in the unlikely case that image is already smaller than a preview |
767 preview_path = path | 767 preview_path = path |
768 else: | 768 else: |
777 with client.cache.cacheData( | 777 with client.cache.cacheData( |
778 source='HOST_PREVIEW', | 778 source='HOST_PREVIEW', |
779 uid=uid, | 779 uid=uid, |
780 filename=filename) as cache_f: | 780 filename=filename) as cache_f: |
781 | 781 |
782 preview_path = await images.resizeImage( | 782 preview_path = await image.resize( |
783 path, | 783 path, |
784 new_size=report['recommended_size'], | 784 new_size=report['recommended_size'], |
785 dest=cache_f | 785 dest=cache_f |
786 ) | 786 ) |
787 | 787 |