示例#1
0
    def get(self, id):
        """
        Get deep zoom image
        ---
        tags:
          - Deep Zoom
        parameters:
          - in: path
            name: id
            description: MonogDB ObjectId -- Example 57bf3c092f9b2e1595b29730
            type: string
        responses:
          200:
            description: Returns the slide information
          404:
          	description: Invalid slide Id or slide not found
        """

        if not ObjectId.is_valid(id):
            resp = {"status": 404, "message": "Invalid slide Id " + id}
            return Response(dumps(resp),
                            status=404,
                            mimetype='application/json')

        image = self.slides.find_one({'_id': ObjectId(id)})
        path = image["path"]
        slide = get_slide(path)

        if slide == None:
            Response("", status=404, mimetype='application/xml')
        else:
            return Response(slide.get_dzi(self.config['deepzoom_format']),
                            status=200,
                            mimetype='application/xml')
示例#2
0
	def get(self, id):
		"""
        Get deep zoom image
        ---
        tags:
          - Deep Zoom
        parameters:
          - in: path
            name: id
            description: MonogDB ObjectId -- Example 57bf3c092f9b2e1595b29730
            type: string
        responses:
          200:
            description: Returns the slide information
          404:
          	description: Invalid slide Id or slide not found
        """

		if not ObjectId.is_valid(id):
			resp = {"status": 404, "message": "Invalid slide Id " + id}
			return Response(dumps(resp), status=404, mimetype='application/json')

		image = self.slides.find_one({'_id': ObjectId(id)})
		path = image["path"]
		slide = get_slide(path)

		if slide == None:
			Response("", status=404, mimetype='application/xml')
		else:
			return Response(slide.get_dzi(self.config['deepzoom_format']), status=200, mimetype='application/xml')
示例#3
0
    def get(self, path, level, x, y):
        """
        Get slide tile
        ---
        tags:
          - Tile
        parameters:
          - in: path
            name: path
            description: Example SLIDES/ADRC/DG_ADRC_Slides/ADRC59-164/aBeta/ADRC59-164_1A_AB.ndpi
            type: string
            required: true
            default: ""
          - in: path
            name: level
            description: The zoom level
            type: integer
            required: true
            default: ""
          - in: path
            name: x
            description: The column
            type: integer
            required: true
            default: ""
          - in: path
            name: y
            description: The row
            type: integer
            required: true
            default: ""
        responses:
          200:
            description: Returns the tile
          404:
          	description: Invalid path or openslide error
		"""

        path = "/" + path

        if not os.path.exists(path):
            resp = {"status": 404, "message": "Path not found: " + path}
            return Response(dumps(resp),
                            status=404,
                            mimetype='application/json')

        slide = get_slide(path)

        try:
            tile = slide.get_tile(level, (x, y))
            buf = cStringIO.StringIO()
            tile.save(buf, format='jpeg', quality=90)
            return Response(buf.getvalue(), status=200, mimetype='image/jpeg')
        except OpenSlideError, e:
            resp = {"status": 404, "message": "OpenSlideError: " + str(e)}
            return Response(dumps(resp),
                            status=404,
                            mimetype='application/json')
示例#4
0
    def get(self, id, level, x, y):
        """
        Get slide tile
        ---
        tags:
          - Tile
        parameters:
          - in: path
            name: id
            description: MonogDB ObjectId appended to it the level -- Example 57bf3c092f9b2e1595b29730
            type: string
          - in: path
            name: level
            description: The zoom level
            type: integer
          - in: path
            name: x
            description: The column
            type: integer
          - in: path
            name: y
            description: The row
            type: integer
        responses:
          200:
            description: Returns the slide information
          404:
          	description: Invalid slide Id or slide not found
        """

        if not ObjectId.is_valid(id):
            resp = {"status": 404, "message": "Invalid slide Id " + id}
            return Response(dumps(resp),
                            status=404,
                            mimetype='application/json')

        image = self.slides.find_one({'_id': ObjectId(id)})
        path = image["path"]
        slide = get_slide(path)

        try:
            tile = slide.get_tile(level, (x, y))
            buf = PILBytesIO()
            tile.save(buf, 'jpeg', quality=90)
            return Response(buf.getvalue(), status=200, mimetype='image/jpeg')
        except ValueError:
            Response(None, status=404)
示例#5
0
	def get(self, id, level, x, y):
		"""
        Get slide tile
        ---
        tags:
          - Tile
        parameters:
          - in: path
            name: id
            description: MonogDB ObjectId appended to it the level -- Example 57bf3c092f9b2e1595b29730
            type: string
          - in: path
            name: level
            description: The zoom level
            type: integer
          - in: path
            name: x
            description: The column
            type: integer
          - in: path
            name: y
            description: The row
            type: integer
        responses:
          200:
            description: Returns the slide information
          404:
          	description: Invalid slide Id or slide not found
        """

		if not ObjectId.is_valid(id):
			resp = {"status": 404, "message": "Invalid slide Id " + id}
			return Response(dumps(resp), status=404, mimetype='application/json')

		image = self.slides.find_one({'_id': ObjectId(id)})
		path = image["path"]
		slide = get_slide(path)
		
		try:
			tile = slide.get_tile(level, (x, y))
			buf = PILBytesIO()
			tile.save(buf, 'jpeg', quality=90)
			return Response(buf.getvalue(), status=200, mimetype='image/jpeg')
		except ValueError:
			Response(None, status=404)
示例#6
0
    def get(self, path):
        """
        Get XML metadata fo the deep zoom image
        ---
        tags:
          - Deep Zoom
        parameters:
          - in: path
            name: path
            description: Example SLIDES/ADRC/DG_ADRC_Slides/ADRC59-164/aBeta/ADRC59-164_1A_AB.ndpi
            type: string
            required: true
            default: "" 
        responses:
          200:
            description: XML metadata for the Deep Zoom file
          404:
          	description: Invalid path or openslide error
		"""

        path = "/" + path

        if not os.path.exists(path):
            resp = {"status": 404, "message": "Path not found: " + path}
            return Response(dumps(resp),
                            status=404,
                            mimetype='application/json')

        slide = get_slide(path)

        if slide == None:
            Response("", status=404, mimetype='application/xml')
        else:
            return Response(slide.get_dzi(self.config['deepzoom_format']),
                            status=200,
                            mimetype='application/xml')