Skip to content

Commit

Permalink
Basic first pass at canvas thumbnails for book, audio, and movies
Browse files Browse the repository at this point in the history
  • Loading branch information
hadro committed Jul 28, 2023
1 parent 367ebe9 commit 55b9ead
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions iiify/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,16 @@ def create_manifest3(identifier, domain=None, page=None):

addMetadata(manifest, identifier, metadata['metadata'])

try:
thumbnail = [{
"id": f"https://archive.org/download/{identifier}/__ia_thumb.jpg",
"type": "Image",
"format": "image/jpeg",
}]
except:
pass


if mediatype == 'texts':
# Get bookreader metadata (mostly for filenames and height / width of image)
# subprefix can be different from the identifier use the scandata filename to find the correct prefix
Expand Down Expand Up @@ -355,7 +365,7 @@ def create_manifest3(identifier, domain=None, page=None):
imgId = f"{zipFile}/{fileName}".replace('/','%2f')
imgURL = f"{IMG_SRV}/3/{imgId}"

canvas = Canvas(id=f"https://iiif.archivelab.org/iiif/{identifier}${pageCount}/canvas", label=f"{page['leafNum']}")
canvas = Canvas(id=f"https://iiif.archivelab.org/iiif/{identifier}${pageCount}/canvas", label=f"{page['leafNum']}", thumbnail=thumbnail)

body = ResourceItem(id=f"{imgURL}/full/max/0/default.jpg", type="Image")
body.format = "image/jpeg"
Expand Down Expand Up @@ -395,7 +405,11 @@ def create_manifest3(identifier, domain=None, page=None):
normalised_id = file['name'].rsplit(".", 1)[0]
slugged_id = normalised_id.replace(" ", "-")
c_id = f"https://iiif.archivelab.org/iiif/{identifier}/{slugged_id}/canvas"
c = Canvas(id=c_id, label=normalised_id, duration=float(file['length']))

try:
c = Canvas(id=c_id, label=normalised_id, duration=float(file['length']), thumbnail=thumbnail)
except:
c = Canvas(id=c_id, label=normalised_id, duration=float(file['length']))

# create intermediary objects
ap = AnnotationPage(id=f"https://iiif.archivelab.org/iiif/{identifier}/{slugged_id}/page")
Expand Down Expand Up @@ -448,7 +462,12 @@ def create_manifest3(identifier, domain=None, page=None):
normalised_id = file['name'].rsplit(".", 1)[0]
slugged_id = normalised_id.replace(" ", "-")
c_id = f"https://iiif.archivelab.org/iiif/{identifier}/{slugged_id}/canvas"
c = Canvas(id=c_id, label=normalised_id, duration=float(file['length']), height=int(file['height']), width=int(file['width']))

try:
c = Canvas(id=c_id, label=normalised_id, duration=float(file['length']), height=int(file['height']), width=int(file['width']),
thumbnail=thumbnail)
except:
c = Canvas(id=c_id, label=normalised_id, duration=float(file['length']), height=int(file['height']), width=int(file['width']))

# create intermediary objects
ap = AnnotationPage(id=f"https://iiif.archivelab.org/iiif/{identifier}/{slugged_id}/page")
Expand Down

0 comments on commit 55b9ead

Please sign in to comment.