示例#1
0
    fh.close()
    print('Manifest for ' + ms[0] + ' saved')

for ms in sheet.iter_rows(min_row=3, values_only=True):
    if (ms[2] == None) and (ms[0] not in ranges_done): # Check that it's not a range row.
        manifests.append(ms[0]) # Add it to the list of created manifests
        title = ms[0]
        manifest = fac.manifest(ident="manifest/" + ms[1] + ".json", label=title)
        manifest.set_metadata({"Physical description": ms[4], 'Bibliography': ms[8], 'Library record ID': str(ms[9])})
        manifest.attribution = "<span>Photo: © Archives & Special Collections, University of Glasgow Library. Terms of use: <a href=\"https://creativecommons.org/licenses/by-nc/4.0/\">CC-BY-NC</a></span>"
        if ms[7] != None:
            manifest.set_metadata({"Commentary": ms[7]})
        manifest.description = ms[6]
        seq = manifest.sequence(ident=ms[1] + ".json", label='Current page order')
        image_dir = "/Users/luca/Documents/development/iiif-prezi/images/" + ms[1] + "/images/"
        fac.set_base_image_dir(image_dir)
        fac.set_base_image_uri("https://iiif.gla.ac.uk/iiif/" + ms[1] + "/images")
        print('Getting data for ' + ms[0])
        for fn in sorted(os.listdir(image_dir)):
            if fn.endswith(".jp2"): # Makes sure that it picks up only images
                ident = fn[:-4]
                cvs_title = ident.replace("_", " ").title().split(' ')[-1]
                cvs = seq.canvas(ident=ident, label=cvs_title)
                #cvs.add_image_annotation(fn, True)

                anno = cvs.annotation(ident=ident + ".json", label=title)
                image = anno.image(ident=fn, iiif=True)
                image.set_hw_from_iiif()
                cvs.set_hw(image.height, image.width)

        if ms[0] not in ms_with_ranges: # If it's not a ms with ranges add the title and save the manifest
"""iiif-prezi example code to build a manifest from a directory of images

"""

from iiif_prezi.factory import ManifestFactory
import os

image_dir = "/path/to/images"
prezi_dir = "/tmp"

fac = ManifestFactory()
fac.set_debug("error")
fac.set_base_image_uri("http://localhost/iiif")
fac.set_base_image_dir(image_dir)
fac.set_iiif_image_info()
fac.set_base_metadata_uri("http://localhost/prezi/")
fac.set_base_metadata_dir(prezi_dir)

mflbl = os.path.split(image_dir)[1].replace("_", " ").title()

mfst = fac.manifest(label=mflbl)
seq = mfst.sequence()
for fn in os.listdir(image_dir):
	ident = fn[:-4]
	title = ident.replace("_", " ").title()
	cvs = seq.canvas(ident=ident, label=title)
	cvs.add_image_annotation(ident, True)

mfst.toFile(compact=False)