Ejemplo n.º 1
0
def get_annotations(collection_id, item_id):
    annotations_json = {}
    item = items.get_item(item_id)
    first_image_id = ""
    for image_id in item["images"]:
        if first_image_id == "":
            first_image_id = image_id
            image = images.get_image(image_id)
            annotations_json["http://localhost:4000/data/" + collection_id +
                             "/" + item_id + "/" + image_id +
                             ".json"] = image["annotations"]
    return jsonify(annotations_json), 200
Ejemplo n.º 2
0
def get_image_info(collection, item, uuid):
    image = images.get_image(uuid)

    data = {
        "@context":
        "http://iiif.io/api/image/2/context.json",
        "@id":
        config.host + "/data/" + collection + "/" + item + "/" + uuid,
        "protocol":
        "http://iiif.io/api/image",
        "width":
        image["meta"]["width"],
        "height":
        image["meta"]["height"],
        "sizes": [{
            "width": 206,
            "height": 152
        }, {
            "width": 309,
            "height": 238
        }],
        "tiles": [{
            "width": 256,
            "height": 256,
            "scaleFactors": [1, 2, 4, 8, 16, 32]
        }],
        "profile": [
            "http://iiif.io/api/image/2/level1.json", {
                "formats": ["jpg"],
                "qualities": ["native", "color", "gray", "bitonal"],
                "supports": [
                    "regionByPct", "regionSquare", "sizeByForcedWh",
                    "sizeByWh", "sizeAboveFull", "rotationBy90s", "mirroring"
                ],
                "maxWidth":
                1000,
                "maxHeight":
                1000
            }
        ]
    }
    return jsonify(data), 200
Ejemplo n.º 3
0
def get_image(collection, item, uuid, region, size, rotation, quality):

    quality = quality.replace(".jpg", "")
    quality = quality.replace(".tif", "")
    quality = quality.replace(".png", "")
    file_extension = images.get_image(uuid)["file-extension"]

    image_path = "webapp/data/" + collection + "/" + item + "/" + uuid + "." + file_extension
    # check if file exists
    if path.exists(image_path):
        print("image file found")
    else:
        print("image file not found")
    image = IIIFImageAPIWrapper.open_image(image_path)
    image.apply_api(region=region,
                    size=size,
                    rotation=rotation,
                    quality=quality)

    return send_file(image.serve(), mimetype='image/jpeg')
Ejemplo n.º 4
0
def get_plain_annotations(item_id):
    annotations_json = {}
    item = items.get_item(item_id)
    page_id = 0
    for image_id in item["images"]:
        image = images.get_image(image_id)
        if "annotations" in image:
            annotations_json[page_id] = {}
            annotation_id = 0
            objects = []
            for obj in image["annotations"]:
                objects.append({
                    "value":
                    obj["resource"][0]["chars"],
                    "location":
                    obj["on"][0]["selector"]["default"]["value"]
                })
                annotation_id += 1
            annotations_json[page_id] = objects
        page_id += 1

    return jsonify(annotations_json), 200
Ejemplo n.º 5
0
def get_manifest(collection_id, item_id):
    item = items.get_item(item_id)
    # generate json for images
    image_json = []
    first_image_id = ""
    for image_id in item["images"]:
        if first_image_id == "":
            first_image_id = image_id
        image_json.append(
            generate_image_in_manifest(collection_id, item_id,
                                       images.get_image(image_id)))

    manifest = {
        "@context":
        "http://iiif.io/api/presentation/2/context.json",
        "@id":
        config.host + "/" + collection_id + "/" + item_id,
        "@type":
        "sc:Manifest",
        "attribution":
        item["meta"]["attribution"],
        "metadata":
        item["metadata"],
        "label":
        item["meta"]["label"],
        "logo":
        item["meta"]["logo"],
        "service": {
            "@context": "http://iiif.io/api/search/1/context.json",
            "@id": "http://exist.scta.info/exist/apps/scta/iiif/pg-lon/search",
            "profile": "http://iiif.io/api/search/1/search",
            "label": "Search within this manifest"
        },
        "rendering": {
            "@id": config.host + "/",
            "format": "text/html",
            "label": "Full record view"
        },
        "sequences": [{
            "@id":
            config.host + "/" + collection_id + "/" + item_id + "/" +
            first_image_id + ".json",
            "@type":
            "sc:Sequence",
            "label":
            "Default",
            "canvases":
            image_json
        }],
        "thumbnail": {
            "@id":
            config.host + "/data" + collection_id + "/" + item_id + "/" +
            first_image_id + "/full/,200/0/default",
            "service": {
                "@context":
                "http://iiif.io/api/image/2/context.json",
                "@id":
                config.host + "/data/" + collection_id + "/" + item_id + "/" +
                first_image_id,
                "profile":
                "http://iiif.io/api/image/2/level2.json"
            }
        },
        "within":
        config.host + "/"
    }

    return jsonify(manifest), 200