{"id":13740980,"url":"https://github.com/giacomomarchioro/pyIIIFpres","last_synced_at":"2025-05-08T20:33:00.437Z","repository":{"id":40363225,"uuid":"333341052","full_name":"giacomomarchioro/pyIIIFpres","owner":"giacomomarchioro","description":"Python module for easing the construction of JSON manifests compliant with IIIF API 3.0.","archived":false,"fork":false,"pushed_at":"2025-01-20T09:50:18.000Z","size":1342,"stargazers_count":20,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T23:03:27.230Z","etag":null,"topics":["api3","iiif","iiif-presentation","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/giacomomarchioro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-27T07:38:36.000Z","updated_at":"2025-02-27T11:38:43.000Z","dependencies_parsed_at":"2024-10-25T17:43:25.713Z","dependency_job_id":"59504ee4-7dc2-4021-b7fd-469e624c4a49","html_url":"https://github.com/giacomomarchioro/pyIIIFpres","commit_stats":{"total_commits":166,"total_committers":3,"mean_commits":"55.333333333333336","dds":"0.030120481927710885","last_synced_commit":"5ffdb3f1adfb22c0e37aa82c6d937289401d7a46"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacomomarchioro%2FpyIIIFpres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacomomarchioro%2FpyIIIFpres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacomomarchioro%2FpyIIIFpres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giacomomarchioro%2FpyIIIFpres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giacomomarchioro","download_url":"https://codeload.github.com/giacomomarchioro/pyIIIFpres/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253145149,"owners_count":21861195,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api3","iiif","iiif-presentation","python3"],"created_at":"2024-08-03T04:00:54.182Z","updated_at":"2025-05-08T20:33:00.380Z","avatar_url":"https://github.com/giacomomarchioro.png","language":"Python","funding_links":[],"categories":["Presentation API Libraries"],"sub_categories":["Image viewers (Image API only)"],"readme":"# pyIIIFpres\n![Build Status](https://github.com/giacomomarchioro/pyIIIFpres/actions/workflows/python-package.yml/badge.svg)[![Coverage Status](https://coveralls.io/repos/github/giacomomarchioro/pyIIIFpres/badge.svg?branch=main)](https://coveralls.io/github/giacomomarchioro/pyIIIFpres?branch=main)[![Documentation Status](https://readthedocs.org/projects/pyiiifpres/badge/?version=latest)](https://pyiiifpres.readthedocs.io/en/latest/?badge=latest)\n----------------\nThis is a Python module built for easing the construction of JSON manifests compliant with IIIF [API 3.0](https://iiif.io/api/presentation/3.0/) in a production environment, similarly to [iiif-prezi](https://github.com/iiif-prezi/iiif-prezi) for earlier versions of the protocol.\n\n## Installation\nThe library uses only standard libraries and can be installed using `pip`.\n\nStable version:\n\n    pip install pyIIIFpres\n\nDevelopment :\n\n    pip install git+https://github.com/giacomomarchioro/pyIIIFpres\n\n## Basic usage\nThe module maps the API structure to Python classes. The user `set_` objects that can have only one value (e.g. `id`) and `add_` objects that can have multiple entities (e.g. `labels`).\nAs an example, we will execute the [Simple Manifest - Book recipe](https://iiif.io/api/cookbook/recipe/0009-book-1/) from the IIIF cookbook. More examples from the [cookbook](https://iiif.io/api/cookbook/) are in the examples folder of this repository.\n\n```python\nfrom IIIFpres import iiifpapi3\niiifpapi3.BASE_URL = \"https://iiif.io/api/cookbook/recipe/0009-book-1/\"\nmanifest = iiifpapi3.Manifest()\nmanifest.set_id(extendbase_url=\"manifest.json\")\nmanifest.add_label(\"en\",\"Simple Manifest - Book\")\nmanifest.add_behavior(\"paged\")\n\n#        label       width height id                                                                            service  \ndata = ((\"Blank page\",3204,4613,\"https://iiif.io/api/image/3.0/example/reference/59d09e6773341f28ea166e9f3c1e674f-gallica_ark_12148_bpt6k1526005v_f18\",\"/full/max/0/default.jpg\"),\n        (\"Frontispiece\",3186,4612,\"https://iiif.io/api/image/3.0/example/reference/59d09e6773341f28ea166e9f3c1e674f-gallica_ark_12148_bpt6k1526005v_f19\",\"/full/max/0/default.jpg\"),\n        (\"Title page\",3204,4613,\"https://iiif.io/api/image/3.0/example/reference/59d09e6773341f28ea166e9f3c1e674f-gallica_ark_12148_bpt6k1526005v_f20\",\"/full/max/0/default.jpg\"),\n        (\"Blank page\",3174,4578,\"https://iiif.io/api/image/3.0/example/reference/59d09e6773341f28ea166e9f3c1e674f-gallica_ark_12148_bpt6k1526005v_f21\",\"/full/max/0/default.jpg\"),\n        (\"Bookplate\",3198,4632,\"https://iiif.io/api/image/3.0/example/reference/59d09e6773341f28ea166e9f3c1e674f-gallica_ark_12148_bpt6k1526005v_f22\",\"/full/max/0/default.jpg\"),)\n\nfor idx,d in enumerate(data):\n    idx+=1 \n    canvas = manifest.add_canvas_to_items()\n    canvas.set_id(extendbase_url=\"canvas/p%s\"%idx) # in this case we use the base url\n    canvas.set_height(d[2])\n    canvas.set_width(d[1])\n    canvas.add_label(\"en\",d[0])\n    annopage = canvas.add_annotationpage_to_items()\n    annopage.set_id(extendbase_url=\"page/p%s/1\" %idx)\n    annotation = annopage.add_annotation_to_items(target=canvas.id)\n    annotation.set_id(extendbase_url=\"annotation/p%s-image\"%str(idx).zfill(4))\n    annotation.set_motivation(\"painting\")\n    annotation.body.set_id(\"\".join(d[3:]))\n    annotation.body.set_type(\"Image\")\n    annotation.body.set_format(\"image/jpeg\")\n    annotation.body.set_width(d[1])\n    annotation.body.set_height(d[2])\n    s = annotation.body.add_service()\n    s.set_id(d[3])\n    s.set_type(\"ImageService3\")\n    s.set_profile(\"level1\")\n\nmanifest.json_save(\"manifest.json\")\n```\n\n## Debug the manifest\nWhen you are populating a new IIIF type from scratch some helpful functions can be\nused for spotting errors.\n\n`.inspect()` method returns a JSON representation of the object where the \nrecommended and required fields are shown:\n\n```python\nfrom IIIFpres import iiifpapi3\nmanifest = iiifpapi3.Manifest()\nmanifest.inspect()\n```\n\n`.show_errors_in_browser()` method opens a new browser tab highlighting the \nrequired and recommended fields.\n\n```python\nmanifest.show_errors_in_browser()\n```\n\n## Reading the manifest (experimental)\nA JSON file compliant with presentation API3 can be read as follows:\n```python\nfrom IIIFpres.utilities import read_API3_json\nmymanifest = read_API3_json('manifest.json')\n```\nThis map Canvas, Annotation and the major IIIF types to iiifpapi3 classes, loading the rests as dicts.\n\nSee the [project wiki](https://github.com/giacomomarchioro/pyIIIFpres/wiki)  or read the complete documentation on [readthedocs.io](https://pyiiifpres.readthedocs.io/) for  information regarding [getting image sizes automatically](https://github.com/giacomomarchioro/pyIIIFpres/wiki/Getting-image-sizes-automatically), [improve the writing performance](https://github.com/giacomomarchioro/pyIIIFpres/wiki/Improve-performance-of-writing-and-serving-JSON-IIIF-objects) and more.\n\n\n## Acknowledgements\nThe package is provided by the [Laboratorio di Studi Medievali e Danteschi](https://sites.hss.univr.it/laboratori_integrati/laboratorio-lamedan/) of the [University of Verona](https://www.univr.it/en/home)\n\n\u003cimg src=\"https://i.ibb.co/tcTNXRP/layerlores.png\" alt=\"LaMeDan Logo\" width=\"250\"\u003e\n\n\nBesides contributors, I would like to thank  [dnoneill](https://github.com/dnoneill) for suggestions, and IIIF community and coordinators.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiacomomarchioro%2FpyIIIFpres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiacomomarchioro%2FpyIIIFpres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiacomomarchioro%2FpyIIIFpres/lists"}