Esempio n. 1
0
 def generate_deep_zoom(self, jekyll_site_dir):
     self.log_status('Downloading deep zoom images')
     imagedir = os.path.join(jekyll_site_dir, self.image_dir)
     # If exporting to GitHub, add the repo name to the path.
     _prefix = os.path.join(os.sep, self.github_repo, self.image_dir) if self.github_repo else os.path.join(os.sep, self.image_dir)
     staticgen = IIIFStatic(dst=imagedir, prefix=_prefix)
     for teipage in self.tei.page_list:
         for graphic in teipage.graphics:
             if graphic.rend == 'full':
                 imgsrc = os.path.join(jekyll_site_dir, graphic.url)
                 iiif_img = IIIFImageClient.init_from_url(graphic.url)
                 staticgen.generate(imgsrc, identifier=iiif_img.image_id)
Esempio n. 2
0
 def generate_deep_zoom(self, jekyll_site_dir):
     self.log_status('Downloading deep zoom images')
     imagedir = os.path.join(jekyll_site_dir, self.image_dir)
     # If exporting to GitHub, add the repo name to the path.
     _prefix = os.path.join(
         os.sep, self.github_repo,
         self.image_dir) if self.github_repo else os.path.join(
             os.sep, self.image_dir)
     staticgen = IIIFStatic(dst=imagedir, prefix=_prefix)
     for teipage in self.tei.page_list:
         for graphic in teipage.graphics:
             if graphic.rend == 'full':
                 imgsrc = os.path.join(jekyll_site_dir, graphic.url)
                 iiif_img = IIIFImageClient.init_from_url(graphic.url)
                 staticgen.generate(imgsrc, identifier=iiif_img.image_id)
Esempio n. 3
0
def get_image_url_from_iiif_url(iiif_url, input_size=224):
    try:
        image = IIIFImageClient.init_from_url(iiif_url)
    except ParseError:
        raise ValueError(f"{iiif_url} is not a valid iiif URL")

    if "dlcs" in image.api_endpoint:
        # DLCS provides a thumbnails service which only serves certain sizes of
        # image. Requests for these don't touch the image server and so, as
        # we're performing lots of requests, we use 400x400 thumbnails and
        # resize them ourselves later on.
        image.api_endpoint = image.api_endpoint.replace("iiif-img", "thumbs")
        # `exact=True` equates to a `/!400,400/` image request
        # https://iiif.io/api/image/1.0/#4-2-size
        return str(image.size(width=400, height=400, exact=True))

    return str(image.size(width=input_size, height=input_size, exact=False))
Esempio n. 4
0
 def iiif_url_to_local_path(self, imgurl):
     '''Convert an IIIF Image API url to a local path that can be
     referenced within the jekyll site.
     '''
     # check if we have an info url, so that it can be duplicated
     is_info = imgurl.endswith('info.json')
     iiif_img = IIIFImageClient.init_from_url(imgurl)
     # convert api endpoint to local path
     iiif_img.api_endpoint = self.image_dir
     # simplify image id: strip out iiif id prefix and pidspace
     # prefix, if possible
     # (leaving any id suffix, since those are likely needed to
     # guarantee uniqueness)
     iiif_img.image_id = iiif_img.image_id \
         .replace(settings.IIIF_ID_PREFIX, '') \
         .replace('%s:' % settings.FEDORA_PIDSPACE, '')
     # serialize updated iiif image url for use as local image path
     if is_info:
         return unicode(iiif_img.info())
     return unicode(iiif_img)
Esempio n. 5
0
 def iiif_url_to_local_path(self, imgurl):
     '''Convert an IIIF Image API url to a local path that can be
     referenced within the jekyll site.
     '''
     # check if we have an info url, so that it can be duplicated
     is_info = imgurl.endswith('info.json')
     iiif_img = IIIFImageClient.init_from_url(imgurl)
     # convert api endpoint to local path
     iiif_img.api_endpoint = self.image_dir
     # simplify image id: strip out iiif id prefix and pidspace
     # prefix, if possible
     # (leaving any id suffix, since those are likely needed to
     # guarantee uniqueness)
     iiif_img.image_id = iiif_img.image_id \
         .replace(settings.IIIF_ID_PREFIX, '') \
         .replace('%s:' % settings.FEDORA_PIDSPACE, '')
     # serialize updated iiif image url for use as local image path
     if is_info:
         return unicode(iiif_img.info())
     return unicode(iiif_img)