示例#1
0
    def test_render(self):
        """Does not parse, uses PARAMS dict to render tile"""
        with IIIF.render(TEST_IMG_PATH, **Parse.uri(TEST_URI)) as t1:
            with IIIF.render(TEST_IMG_PATH, **PARAMS) as t2:
                self.assertTrue(t1.contents() == t2.contents(),
                                "Parsing uri behaving differently "
                                "than PARAMS")

                im = Image.open(t1)
                self.assertTrue(im.size == (1000, EXPECTED_HEIGHT),
                                "Tile is the wrong dimensions: "
                                "Expected %s got %s."
                                % ((1000, EXPECTED_HEIGHT), im.size))
                im.close()
示例#2
0
def iiif(**kwargs):
    """ Return a cached tile or a real tile"""
    cache_id = web.urihash(request.url)
    cached_tile = os.path.join(PATH, 'cache', '%s' % cache_id)
    params = web.Parse.params(**kwargs)
    path = resolve(params.get('identifier'))
    if os.path.isfile(cached_tile):
        print "returning cached image"
        return send_file(open(cached_tile), mimetype="image/jpeg")

    else:
        with IIIF.render(path, **params) as tile:
            print cache_id
            tile.save(cached_tile)
            return send_file(tile, mimetype=tile.mime)
示例#3
0
文件: app.py 项目: mekarpeles/iiif2
def iiif(**kwargs):
    params = web.Parse.params(**kwargs)
    path = resolve(params.get('identifier'))
    with IIIF.render(path, **params) as tile:
        return send_file(tile, mimetype=tile.mime)