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:
parent
fb2dc9b7a0
commit
93a4e488ea
2 changed files with 197 additions and 0 deletions
|
|
@ -361,6 +361,13 @@ class Const(object):
|
|||
# internationalisation
|
||||
DEFAULT_LOCALE = "en_GB"
|
||||
|
||||
# Contexts
|
||||
# context indicate how things are done (e.g. to who/what a file is transfered)
|
||||
# this is useful to make some decision (e.g. image size)
|
||||
|
||||
# something is done in instant messaging
|
||||
CONTEXT_CHAT = "CONTEXT_CHAT"
|
||||
|
||||
## Misc ##
|
||||
SAVEFILE_DATABASE = APP_NAME_FILE + ".db"
|
||||
IQ_SET = '/iq[@type="set"]'
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue