core: added imageCheck and imageResize methods:

imageCheck will give a report on image, notably it will tell if it's too big and needs to
be resized before a transfer.

imageResize will create a new image with the requested size and return a path to it.
This commit is contained in:
Goffi 2019-10-29 20:38:39 +01:00
commit 93a4e488ea

View file

@ -40,8 +40,10 @@ from sat.memory import cache
from sat.memory import encryption
from sat.tools import async_trigger as trigger
from sat.tools import utils
from sat.tools import images
from sat.tools.common import dynamic_import
from sat.tools.common import regex
from sat.tools.common import data_format
from sat.stdui import ui_contact_list, ui_profile_manager
import sat.plugins
@ -161,6 +163,8 @@ class SAT(service.Service):
self.bridge.register_method("loadParamsTemplate", self.memory.load_xml)
self.bridge.register_method("sessionInfosGet", self.getSessionInfos)
self.bridge.register_method("namespacesGet", self.getNamespaces)
self.bridge.register_method("imageCheck", self._imageCheck)
self.bridge.register_method("imageResize", self._imageResize)
self.memory.initialized.addCallback(self._postMemoryInit)
@ -632,6 +636,17 @@ class SAT(service.Service):
}
return defer.succeed(data)
# images
def _imageCheck(self, path):
report = images.checkImage(self, path)
return data_format.serialise(report)
def _imageResize(self, path, width, height):
d = images.resizeImage(path, (width, height))
d.addCallback(lambda new_image_path: str(new_image_path))
return d
# local dirs
def getLocalPath(self, client, dir_name, *extra_path, **kwargs):