Example #1
0
def make_manifest_json(image_pages, thumbnail_images, identifier, page=None):
    fac = ManifestFactory()
    fac.set_base_prezi_uri(get_manifest_url(''))
    fac.set_debug("error")
    if page is None:
        page = {
            "title": image_pages[0]['title'],
            "extract": "(single wikimedia image)"
        }
    manifest = fac.manifest(ident=identifier, label=page['title'])
    manifest.description = sanitise(page['extract'])
    sequence = manifest.sequence(ident="normal", label="default order")
    for image_page in image_pages:
        page_id = image_page.get('pageid', None)
        wiki_info = image_page.get('imageinfo', [None])[0]
        if wiki_info is not None and wiki_info['mime'] == "image/jpeg":
            canvas = sequence.canvas(ident='c%s' % page_id,
                                     label=image_page['title'])
            canvas.set_hw(wiki_info['thumbheight'], wiki_info['thumbwidth'])
            set_canvas_metadata(wiki_info, canvas)
            anno = canvas.annotation(ident='a%s' % page_id)
            img = anno.image(ident=wiki_info['thumburl'], iiif=False)
            img.set_hw(wiki_info['thumbheight'], wiki_info['thumbwidth'])
            thumb_page = thumbnail_images.get(str(page_id), None)
            if thumb_page is not None:
                thumb_info = thumb_page['imageinfo'][0]
                canvas.thumbnail = fac.image(ident=thumb_info['thumburl'])
                canvas.thumbnail.format = "image/jpeg"
                canvas.thumbnail.set_hw(thumb_info['thumbheight'],
                                        thumb_info['thumbwidth'])
    return manifest.toJSON(top=True)
Example #2
0
	def buildFactory(self, version):
		"""Return instance of ManifestFactory for correct API version."""
		if self.require_version:
			fac = ManifestFactory(version=self.require_version)
		else:
			fac = ManifestFactory(version=version)
		self.debug_stream = StringIO.StringIO()
		fac.set_debug("warn")
		fac.set_debug_stream(self.debug_stream)
		return fac
Example #3
0
	def buildFactory(self, version):
		"""Return instance of ManifestFactory for correct API version."""
		if self.require_version:
			fac = ManifestFactory(version=self.require_version)
		else:
			fac = ManifestFactory(version=version)
		self.debug_stream = io.StringIO()
		fac.set_debug("warn")
		fac.set_debug_stream(self.debug_stream)
		return fac
Example #4
0
    def get(self, request, *args, **kwargs):
        fec_entity = self.get_object()

        fac = ManifestFactory()
        fac.set_base_prezi_uri(getattr(settings, 'BASE_PREZI_URI', 'http://127.0.0.1:8000/'))

        # Default Image API information
        fac.set_base_image_uri(getattr(settings, 'BASE_IMAGE_URI', 'http://127.0.0.1:8182/iiif/2/'))
        fac.set_iiif_image_info(2.0, 2)
        fac.set_debug("error")

        manifest = fac.manifest(label=fec_entity.title)

        manifest.set_metadata(self.assemble_metadata(fec_entity))
        manifest.viewingDirection = "left-to-right"

        manifest.attribution = 'Radio Free Europe/Free Europe Committee - Encrypted Telex Communication<br/>' \
                               'Vera & Donald Blinken Open Society Archives'

        seq = manifest.sequence()

        for p in range(1, fec_entity.pages + 1):
            # Create a canvas with uri slug of page-p, and label of Page 1
            canvas_id = "fec-%s-page-%s" % (fec_entity.doc_name, str(p))
            cvs = seq.canvas(ident=canvas_id, label="Page %s" % p)
            underscore_idx = fec_entity.doc_name.find('_')

            image_id = urllib.quote_plus(
                "fec/%s/%s_%s_%02d.jpg" % (
                    fec_entity.doc_name[:underscore_idx],
                    fec_entity.doc_name[:underscore_idx],
                    fec_entity.doc_name[underscore_idx + 1:],
                    p
                )
            )

            cvs.set_image_annotation(image_id, iiif=True)

        return self.render_json_response(manifest.toJSON(top=True))
Example #5
0
def make_manifest_json(image_pages, thumbnail_images, identifier, page=None):
    """Generate the raw json for manifest."""
    fac = ManifestFactory()
    fac.set_base_prezi_uri(identifier)
    fac.set_debug('error')
    if page is None:
        page = {
            "title":
            "Media on Wikimedia Commons with the Category: {}".format(
                CATEGORY_STRING),
            "extract":
            "Generated by the ScienceStories.io API"
        }
    manifest = fac.manifest(ident=identifier, label=page['title'])
    manifest.description = sanitise(page['extract'])
    sequence = manifest.sequence(ident="normal", label="default order")
    for image_page in image_pages:
        page_id = image_page.get('pageid', None)
        wiki_info = image_page.get('imageinfo', [None])[0]
        # TODO: Extend support for more MIME Types
        # Currently universalviewer does not support: "image/tiff"
        verified_mimes = ["image/jpeg", "image/png"]
        if wiki_info is not None and wiki_info['mime'] in verified_mimes:
            canvas = sequence.canvas(ident='c%s' % page_id,
                                     label=image_page['title'])
            canvas.set_hw(wiki_info['thumbheight'], wiki_info['thumbwidth'])
            set_canvas_metadata(wiki_info, canvas)
            anno = canvas.annotation(ident='a%s' % page_id)
            img = anno.image(ident=wiki_info['thumburl'], iiif=False)
            img.set_hw(wiki_info['thumbheight'], wiki_info['thumbwidth'])
            thumb_page = thumbnail_images.get(str(page_id), None)
            if thumb_page is not None:
                thumb_info = thumb_page['imageinfo'][0]
                canvas.thumbnail = fac.image(ident=thumb_info['thumburl'])
                canvas.thumbnail.format = "image/jpeg"
                canvas.thumbnail.set_hw(thumb_info['thumbheight'],
                                        thumb_info['thumbwidth'])
    manifest_serialized = manifest.toJSON(top=True)
    return manifest_serialized
Example #6
0
from openpyxl import load_workbook
import os
import warnings
warnings.simplefilter("ignore")

spreadsheet = load_workbook(filename="McLagan_MSGen1042.xlsx", read_only=True)
sheet = spreadsheet.active

manuscripts = ["MS_Gen_1042_1", "MS_Gen_1042_10", "MS_Gen_1042_100", "MS_Gen_1042_101", "MS_Gen_1042_102", "MS_Gen_1042_103", "MS_Gen_1042_104", "MS_Gen_1042_105", "MS_Gen_1042_106a", "MS_Gen_1042_106b", "MS_Gen_1042_107", "MS_Gen_1042_108", "MS_Gen_1042_109", "MS_Gen_1042_11", "MS_Gen_1042_110", "MS_Gen_1042_111", "MS_Gen_1042_112", "MS_Gen_1042_113", "MS_Gen_1042_114", "MS_Gen_1042_115", "MS_Gen_1042_116", "MS_Gen_1042_117", "MS_Gen_1042_118", "MS_Gen_1042_119", "MS_Gen_1042_12", "MS_Gen_1042_120", "MS_Gen_1042_121", "MS_Gen_1042_122", "MS_Gen_1042_123", "MS_Gen_1042_124", "MS_Gen_1042_125", "MS_Gen_1042_126", "MS_Gen_1042_127", "MS_Gen_1042_128", "MS_Gen_1042_129a", "MS_Gen_1042_129b", "MS_Gen_1042_13", "MS_Gen_1042_130", "MS_Gen_1042_132", "MS_Gen_1042_133", "MS_Gen_1042_134", "MS_Gen_1042_135a", "MS_Gen_1042_135b", "MS_Gen_1042_136", "MS_Gen_1042_137", "MS_Gen_1042_138", "MS_Gen_1042_139", "MS_Gen_1042_14", "MS_Gen_1042_140", "MS_Gen_1042_141", "MS_Gen_1042_142", "MS_Gen_1042_143", "MS_Gen_1042_144", "MS_Gen_1042_145", "MS_Gen_1042_146", "MS_Gen_1042_147", "MS_Gen_1042_148", "MS_Gen_1042_149", "MS_Gen_1042_15", "MS_Gen_1042_150", "MS_Gen_1042_151", "MS_Gen_1042_152", "MS_Gen_1042_153", "MS_Gen_1042_154", "MS_Gen_1042_155", "MS_Gen_1042_156", "MS_Gen_1042_157", "MS_Gen_1042_158", "MS_Gen_1042_159", "MS_Gen_1042_16", "MS_Gen_1042_160", "MS_Gen_1042_161", "MS_Gen_1042_162", "MS_Gen_1042_163", "MS_Gen_1042_164", "MS_Gen_1042_165a", "MS_Gen_1042_165b", "MS_Gen_1042_166", "MS_Gen_1042_167", "MS_Gen_1042_168", "MS_Gen_1042_169", "MS_Gen_1042_17", "MS_Gen_1042_170", "MS_Gen_1042_171", "MS_Gen_1042_172", "MS_Gen_1042_173", "MS_Gen_1042_174", "MS_Gen_1042_175", "MS_Gen_1042_176", "MS_Gen_1042_177", "MS_Gen_1042_178", "MS_Gen_1042_179", "MS_Gen_1042_18", "MS_Gen_1042_180", "MS_Gen_1042_181", "MS_Gen_1042_182", "MS_Gen_1042_183", "MS_Gen_1042_184", "MS_Gen_1042_185", "MS_Gen_1042_186", "MS_Gen_1042_187", "MS_Gen_1042_188", "MS_Gen_1042_189", "MS_Gen_1042_19", "MS_Gen_1042_190", "MS_Gen_1042_191", "MS_Gen_1042_192", "MS_Gen_1042_193", "MS_Gen_1042_194", "MS_Gen_1042_195", "MS_Gen_1042_196", "MS_Gen_1042_197", "MS_Gen_1042_198", "MS_Gen_1042_199", "MS_Gen_1042_2", "MS_Gen_1042_20", "MS_Gen_1042_200", "MS_Gen_1042_201", "MS_Gen_1042_203", "MS_Gen_1042_204", "MS_Gen_1042_205", "MS_Gen_1042_206", "MS_Gen_1042_207", "MS_Gen_1042_208", "MS_Gen_1042_209", "MS_Gen_1042_21", "MS_Gen_1042_210", "MS_Gen_1042_211", "MS_Gen_1042_212", "MS_Gen_1042_213", "MS_Gen_1042_214", "MS_Gen_1042_216", "MS_Gen_1042_217", "MS_Gen_1042_218", "MS_Gen_1042_219", "MS_Gen_1042_22", "MS_Gen_1042_220", "MS_Gen_1042_221", "MS_Gen_1042_222a", "MS_Gen_1042_222b", "MS_Gen_1042_222c", "MS_Gen_1042_223", "MS_Gen_1042_224", "MS_Gen_1042_225", "MS_Gen_1042_226", "MS_Gen_1042_227", "MS_Gen_1042_228", "MS_Gen_1042_229", "MS_Gen_1042_23", "MS_Gen_1042_230", "MS_Gen_1042_231", "MS_Gen_1042_232", "MS_Gen_1042_233", "MS_Gen_1042_234", "MS_Gen_1042_235", "MS_Gen_1042_236", "MS_Gen_1042_237", "MS_Gen_1042_238", "MS_Gen_1042_239", "MS_Gen_1042_24", "MS_Gen_1042_240", "MS_Gen_1042_241", "MS_Gen_1042_242", "MS_Gen_1042_243", "MS_Gen_1042_244", "MS_Gen_1042_245", "MS_Gen_1042_246", "MS_Gen_1042_247", "MS_Gen_1042_248", "MS_Gen_1042_249", "MS_Gen_1042_24a", "MS_Gen_1042_25", "MS_Gen_1042_250", "MS_Gen_1042_251", "MS_Gen_1042_252", "MS_Gen_1042_253", "MS_Gen_1042_254", "MS_Gen_1042_26", "MS_Gen_1042_27", "MS_Gen_1042_28", "MS_Gen_1042_29", "MS_Gen_1042_3", "MS_Gen_1042_30", "MS_Gen_1042_31", "MS_Gen_1042_32", "MS_Gen_1042_33", "MS_Gen_1042_34", "MS_Gen_1042_35", "MS_Gen_1042_36", "MS_Gen_1042_37", "MS_Gen_1042_38", "MS_Gen_1042_39", "MS_Gen_1042_4", "MS_Gen_1042_40", "MS_Gen_1042_41", "MS_Gen_1042_42", "MS_Gen_1042_43", "MS_Gen_1042_44", "MS_Gen_1042_45", "MS_Gen_1042_47", "MS_Gen_1042_48", "MS_Gen_1042_49", "MS_Gen_1042_5", "MS_Gen_1042_50", "MS_Gen_1042_51", "MS_Gen_1042_52", "MS_Gen_1042_53", "MS_Gen_1042_54", "MS_Gen_1042_54a", "MS_Gen_1042_55", "MS_Gen_1042_56", "MS_Gen_1042_57", "MS_Gen_1042_58", "MS_Gen_1042_59", "MS_Gen_1042_60", "MS_Gen_1042_61", "MS_Gen_1042_62", "MS_Gen_1042_63", "MS_Gen_1042_64", "MS_Gen_1042_65", "MS_Gen_1042_66", "MS_Gen_1042_67", "MS_Gen_1042_68", "MS_Gen_1042_69", "MS_Gen_1042_7", "MS_Gen_1042_70", "MS_Gen_1042_71", "MS_Gen_1042_72", "MS_Gen_1042_73", "MS_Gen_1042_74", "MS_Gen_1042_75", "MS_Gen_1042_76", "MS_Gen_1042_77", "MS_Gen_1042_78", "MS_Gen_1042_79", "MS_Gen_1042_79a", "MS_Gen_1042_8", "MS_Gen_1042_80", "MS_Gen_1042_81", "MS_Gen_1042_81a", "MS_Gen_1042_82", "MS_Gen_1042_83", "MS_Gen_1042_84", "MS_Gen_1042_85", "MS_Gen_1042_86", "MS_Gen_1042_87", "MS_Gen_1042_88", "MS_Gen_1042_89", "MS_Gen_1042_9", "MS_Gen_1042_90", "MS_Gen_1042_91", "MS_Gen_1042_92", "MS_Gen_1042_93", "MS_Gen_1042_94", "MS_Gen_1042_95", "MS_Gen_1042_96", "MS_Gen_1042_97", "MS_Gen_1042_98", "MS_Gen_1042_99"]

ms_with_ranges =["MS Gen 1042/10","MS Gen 1042/102","MS Gen 1042/105","MS Gen 1042/106a","MS Gen 1042/106b","MS Gen 1042/109","MS Gen 1042/111","MS Gen 1042/114","MS Gen 1042/115","MS Gen 1042/118","MS Gen 1042/120","MS Gen 1042/122","MS Gen 1042/125","MS Gen 1042/126","MS Gen 1042/129a","MS Gen 1042/129b","MS Gen 1042/13","MS Gen 1042/130","MS Gen 1042/132","MS Gen 1042/135b","MS Gen 1042/136","MS Gen 1042/137","MS Gen 1042/139","MS Gen 1042/14","MS Gen 1042/140","MS Gen 1042/141","MS Gen 1042/142","MS Gen 1042/143","MS Gen 1042/145","MS Gen 1042/146","MS Gen 1042/148","MS Gen 1042/150","MS Gen 1042/151","MS Gen 1042/153","MS Gen 1042/154","MS Gen 1042/156","MS Gen 1042/160","MS Gen 1042/161","MS Gen 1042/162","MS Gen 1042/163","MS Gen 1042/165b","MS Gen 1042/166","MS Gen 1042/167","MS Gen 1042/168","MS Gen 1042/169","MS Gen 1042/170","MS Gen 1042/177","MS Gen 1042/18","MS Gen 1042/180","MS Gen 1042/181","MS Gen 1042/184","MS Gen 1042/185","MS Gen 1042/186","MS Gen 1042/187","MS Gen 1042/19","MS Gen 1042/190","MS Gen 1042/192","MS Gen 1042/193","MS Gen 1042/194","MS Gen 1042/195","MS Gen 1042/199","MS Gen 1042/2","MS Gen 1042/20","MS Gen 1042/200","MS Gen 1042/201","MS Gen 1042/204","MS Gen 1042/205","MS Gen 1042/209","MS Gen 1042/210","MS Gen 1042/211","MS Gen 1042/213","MS Gen 1042/216","MS Gen 1042/219","MS Gen 1042/22","MS Gen 1042/222a","MS Gen 1042/222b","MS Gen 1042/222c","MS Gen 1042/225","MS Gen 1042/226","MS Gen 1042/227","MS Gen 1042/229","MS Gen 1042/23","MS Gen 1042/230","MS Gen 1042/233","MS Gen 1042/235","MS Gen 1042/239","MS Gen 1042/240","MS Gen 1042/241","MS Gen 1042/244","MS Gen 1042/25","MS Gen 1042/26","MS Gen 1042/27","MS Gen 1042/29","MS Gen 1042/3","MS Gen 1042/33","MS Gen 1042/36","MS Gen 1042/39","MS Gen 1042/4","MS Gen 1042/45","MS Gen 1042/47","MS Gen 1042/5","MS Gen 1042/50","MS Gen 1042/51","MS Gen 1042/52","MS Gen 1042/53","MS Gen 1042/54","MS Gen 1042/58","MS Gen 1042/59","MS Gen 1042/61","MS Gen 1042/62","MS Gen 1042/64","MS Gen 1042/67","MS Gen 1042/68","MS Gen 1042/69","MS Gen 1042/70","MS Gen 1042/73","MS Gen 1042/76","MS Gen 1042/77","MS Gen 1042/80","MS Gen 1042/81","MS Gen 1042/82","MS Gen 1042/83","MS Gen 1042/85","MS Gen 1042/87","MS Gen 1042/89","MS Gen 1042/9","MS Gen 1042/90","MS Gen 1042/91","MS Gen 1042/94","MS Gen 1042/96","MS Gen 1042/97","MS Gen 1042/98","MS Gen 1042/99"]

prezi_dir = "/tmp"

fac = ManifestFactory()
fac.set_debug("error")
fac.set_iiif_image_info()
fac.set_base_prezi_uri("https://iiif.gla.ac.uk/")
fac.set_base_prezi_dir(prezi_dir)

ranges_done = []
manifests = []

def save_manifest(ms):
    data = manifest.toString(compact=False)
    fh = open("manifests/" + ms[1] + '.json', mode="w", encoding="utf-8")
    fh.write(data)
    fh.close()
    print('Manifest for ' + ms[0] + ' saved')

for ms in sheet.iter_rows(min_row=3, values_only=True):
Example #7
0
textUris = [BASEURL + "resources/page1.txt", BASEURL + "resources/page2.txt"]
htmlUris = [BASEURL + "resources/page1.html", BASEURL + "resources/page2.html"]
transcriptions = [ 
	["Top of First Page to Display", "Middle of First Page on Angle", "Bottom of First Page to Display"],
	["Top of Second Page to Display", "Middle of Second Page on Angle", "Bottom of Second Page on Angle"]
]

line1Dims = "225,70,750,150"

# Configure the factory
fac = ManifestFactory()
fac.set_base_prezi_uri(BASEURL)
fac.set_base_prezi_dir(HOMEDIR)
fac.set_base_image_uri(IMAGE_BASEURL)
fac.set_iiif_image_info(2.0, 1)
fac.set_debug('error')

testInfo = {

# Done
1 : {"title": "Minimum Required Fields"},
2 : {"title": "Metadata Pairs", 'mfprops': [('metadata',{'date': 'some date'})]},
3 : {"title": "Metadata Pairs with Languages", 'mfprops': [('metadata', {'date': {'en':'some data','fr':'quelquetemps'}})]},
4 : {"title": "Metadata Pairs with Multiple Values in same Language", 'mfprops':[('metadata',{'date': ['some date', 'some other date']})]},
5 : {"title": "Description field", 'mfprops': [('description',"This is a description")]},
6 : {"title": "Multiple Descriptions", 'mfprops': [('description',["This is one description", {"en":"This is another"}])]},
7 : {"title": "Rights Metadata", 'mfprops': [('attribution', "Owning Institution"), ('license','http://creativecommons.org/licenses/by-nc/3.0/')]},
8 : {"title": "SeeAlso link / Manifest", 'mfprops':[('seeAlso','http://www.example.org/link/to/metadata')]},
9 : {"title": "Service link / Manifest", 'mfprops':[('service','http://www.example.org/link/to/searchService')]},
10 : {"title": "Service link as Object"},
11 : {"title": "ViewingDirection: l-t-r", 'ncanvas':2, 'mfprops':[('viewingDirection', 'left-to-right')]},
"""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)
],
                  [
                      "Top of Second Page to Display",
                      "Middle of Second Page on Angle",
                      "Bottom of Second Page on Angle"
                  ]]

line1Dims = "225,70,750,150"

# Configure the factory
fac = ManifestFactory()
fac.set_base_prezi_uri(BASEURL)
fac.set_base_prezi_dir(HOMEDIR)
fac.set_base_image_uri(IMAGE_BASEURL)
fac.set_iiif_image_info(2.0, 1)
fac.set_debug('error')

testInfo = {

    # Done
    1: {
        "title": "Minimum Required Fields"
    },
    2: {
        "title": "Metadata Pairs",
        'mfprops': [('metadata', {
            'date': 'some date'
        })]
    },
    3: {
        "title":