コード例 #1
0
def store_media(manager, ident, description, focus):

    #Send task to create image object
    width, height, mtype = manager.store_media(ident)

    if width:
        description = description or ""
        focus_x = 0
        focus_y = 0

        if focus:
            focus_x, focus_y = focus.split(',')

        m = Media.create(
            media_name=ident,
            height=height,
            width=width,
            focus_x=focus_x,
            focus_y=focus_y,
            media_type=mtype,
            description=description,
        )
コード例 #2
0
def store_media(manager: MediaManager, ident: str, description: str, focus:Tuple[int, int]) -> None:

    #Send task to create image object
    width, height, mtype = manager.store_media(ident)

    if width:
        description = description or ""
        focus_x = 0
        focus_y = 0

        if focus:
            focus_x, focus_y = focus

        m = Media.create(
            media_name = ident,
            height = height,
            width = width,
            focus_x = focus_x,
            focus_y = focus_y,
            media_type = mtype,
            description = description,
        )
コード例 #3
0
ファイル: media.py プロジェクト: Muurtegel/anfora
    def on_post(self, req, resp):
        image = req.get_param('file')

        if image == None:
            raise falcon.HTTPMissingParam('file')

        # Get a free id for the image
        valid = False
        identity = ""
        while not valid:
            ident = str(uuid.uuid4())
            valid = not Media.select().where(
                Media.media_name == identity).exists()

        #Send task to create image object
        width, height, mtype = self.create_image(io.BytesIO(image.file.read()),
                                                 ident)

        description = req.get_param('description') or ""
        focus_x = 0
        focus_y = 0

        if req.get_param('focus'):
            focus_x, focus_y = req.get_param('focus').split(',')

        m = Media.create(
            media_name=ident,
            height=height,
            width=width,
            focus_x=focus_x,
            focus_y=focus_y,
            media_type=mtype,
            description=description,
        )

        resp.body = json.dumps(m.to_json())
        resp.status = falcon.HTTP_200