Skip to main content

IIIF Presentation v3 API implementation

Project description

iiif-prezi3

IIIF Presentation API 3 Python Library

PyPI version PyPI — Python versions PyPI - License CI

Installation

PyPI

The easiest way to install the iiif-prezi3 library is directly from PyPI:

pip install iiif-prezi3

Manual installation

Alternatively, you can clone the repository and run setup.py locally:

git clone https://github.com/iiif-prezi/iiif-prezi3.git

or

git clone git@github.com:iiif-prezi/iiif-prezi3.git

followed by:

cd iiif-prezi3
python setup.py install

Basic Usage

You can now import the library or individual classes from within Python and start creating your IIIF Presentation 3 objects:

Directly creating a Manifest

>>> from iiif_prezi3 import Manifest
>>> m = Manifest(id="https://example.com/iiif/manifest.json", label={"en":["Example Manifest"]})
>>> print(m.json(indent=2))
{
  "@context": "http://iiif.io/api/presentation/3/context.json",
  "id": "https://example.com/iiif/manifest.json",
  "type": "Manifest",
  "label": {
    "en": [
      "Example Manifest"
    ]
  }
}

Importing an existing IIIF Manifest

If you have an existing IIIF Presentation v3 Manifest, you can load it via the built-in json module and create the objects:

>>> from iiif_prezi3 import Manifest
>>> import json
>>> manifest_json = json.load(open("example.json"))
>>> m = Manifest(**manifest_json)
>>> print(m.json(indent=2))
{
  "@context": "http://iiif.io/api/presentation/3/context.json",
  "id": "https://iiif.io/api/cookbook/recipe/0003-mvm-video/manifest.json",
  "type": "Manifest",
  "label": {
    "en": [
      "Video Example 3"
    ]
  },
  "items": [
    {
      "id": "https://iiif.io/api/cookbook/recipe/0003-mvm-video/canvas",
      "type": "Canvas",
      "height": 360,
      "width": 640,
      "duration": 572.034,
      "items": [
        {
          "id": "https://iiif.io/api/cookbook/recipe/0003-mvm-video/canvas/page",
          "type": "AnnotationPage",
          "items": [
            {
              "id": "https://iiif.io/api/cookbook/recipe/0003-mvm-video/canvas/page/annotation",
              "type": "Annotation",
              "motivation": "painting",
              "body": {
                "id": "https://fixtures.iiif.io/video/indiana/lunchroom_manners/high/lunchroom_manners_1024kb.mp4",
                "type": "Video",
                "height": 360,
                "width": 480,
                "duration": 572.034,
                "format": "video/mp4"
              },
              "target": "https://iiif.io/api/cookbook/recipe/0003-mvm-video/canvas"
            }
          ]
        }
      ]
    }
  ]
}

Extensions

iiif-prezi3 includes the capability to load extensions to the IIIF Presentation schema (e.g navPlace) and modify the library's Python classes to include extra properties, validation, helper methods, etc.

Published extensions from the IIIF Registry of Extensions are included with the package, and can be loaded using the iiif_prezi3.load_bundled_extensions() method.

Called without argument, this method will load all bundled extensions listed in the iiif_prezi3/config/extensions.json file. If you wish to only load selected extensions from those available bundled with the library, you can pass either the path to a JSON file, or a list of extension names as an argument to the function:

>>> import iiif_prezi3
>>> iiif_prezi3.load_bundled_extensions(extensions="/path/to/chosen_extensions.json")
>>> import iiif_prezi3
>>> iiif_prezi3.load_bundled_extensions(extensions=['example_extension'])

Extensions work in much the same way as helper methods, and are monkeypatched into the relevant objects in the iiif_prezi3.skeleton class, from which everything is loaded. For a simple example, please see the extensions/example_extension.py file, and the documentation on writing a helper method.

Local Development

For developing iiif-prezi3 locally, clone the repo and then install it and the development dependencies using pip's "editable mode":

git clone git@github.com:iiif-prezi/iiif-prezi3.git
cd iiif-prezi3
pip install -e .[dev]

Running Tests

Tests (including linting) can be run using tox. First, install tox with pip install tox, then type tox.

Versioning

iiif-prezi3 broadly follows Semantic Versioning. Patch releases are used for bug fixes, minor releases add new functionality and maintain backwards compatibility, and major versions contain breaking changes to the public API of the library. Links to the changes between individual versions can be found on the releases page.

Get Involved

The iiif-prezi3 maintainers welcome contributions from the community - issues, pull requests, use cases, etc. We have a guideline document for contributions and a channel #iiif-prezi3 on the IIIF Slack workspace, which can be joined from the IIIF website's Get Involved page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iiif_prezi3-3.1.0.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iiif_prezi3-3.1.0-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

Details for the file iiif_prezi3-3.1.0.tar.gz.

File metadata

  • Download URL: iiif_prezi3-3.1.0.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iiif_prezi3-3.1.0.tar.gz
Algorithm Hash digest
SHA256 c0a477716263798bd711c564b2d592d7aeb346886d3a7b7b7051d21e1f2c075e
MD5 2647483fff4919cffd4f216f2d9e9f77
BLAKE2b-256 76418f1c5f87fc8899a80db4f80db2973d36db3bd5e8fb2c94cfbbd819c3aa85

See more details on using hashes here.

File details

Details for the file iiif_prezi3-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: iiif_prezi3-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 31.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iiif_prezi3-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38473cc7cad65016f5cac83e3f23b2bc135b11d117c5a2f4904d65dff67d789f
MD5 f9d104d4608337518ddb2018a1c5dee4
BLAKE2b-256 3c990f94a23875216f84632655b749a0ce6b5e79a418d3225163a345c094f285

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page