def set_hw_from_iiif(self): if not self._identifier: raise ConfigurationError("Image is not configured with IIIF support") requrl = self._factory.image_base + self._identifier + '/info.json'; try: fh = urllib.urlopen(requrl) data = fh.read() fh.close() except: raise ConfigurationError("Could not get IIIF Info from %s" % requrl) js = json.loads(data) self.height = int(js['height']) self.width = int(js['width'])
def set_hw_from_iiif(self): if not self._identifier: raise ConfigurationError( "Image is not configured with IIIF support") requrl = self._factory.image_base + self._identifier + '/info.json' try: fh = urllib.urlopen(requrl) data = fh.read() fh.close() except: raise ConfigurationError("Could not get IIIF Info from %s" % requrl) js = json.loads(data) self.height = int(js['height']) self.width = int(js['width'])
# BL Flickr TSV + JSON to IIIF Metadata # Data available here: https://github.com/BL-Labs/imagedirectory import sys, os, re import glob import ljson from factory import ManifestFactory fac = ManifestFactory() fac.set_base_metadata_uri("https://github.com/BL-Labs/imagedirectory/iiif") fac.set_base_metadata_dir('/Users/azaroth/Development/bl/imagedirectory/iiif') fh = file('book_metadata.json') data = fh.read() fh.close() books = ljson.loads(data) # volume / Publisher / Title / Author / ? / pub place / book id / book ARK / flickr_url / # image_idx / page / flickr_id / f_small / f_s_height / f_s_width / medium / large / original # Can be images from the same book in multiple TSV files, as based on image size so build in parallel and sort manifests = {} files = glob.glob("*.tsv") files.sort() for f in files: fh = file(f) data = fh.read() fh.close() lines = data.split('\r\n')