Python library for working with IIIF Image and Presentation APIs
Project description
piffle
Python library for generating and parsing IIIF Image API URLs in an object-oriented, pythonic fashion.
Piffle was originally developed by Rebecca Sutton Koeser at Emory University as a part of Readux and forked as a separate project under emory-lits-labs. It was later transferred to Rebecca Sutton Koeser at the Center for Digital Humanities at Princeton.
Installation and example use:
pip install piffle
Example use for generating an IIIF image url:
>>> from piffle.image import IIIFImageClient
>>> myimg = IIIFImageClient('http://image.server/path/', 'myimgid')
>>> print myimg
http://image.server/path/myimgid/full/full/0/default.jpg
>>> print myimg.info()
http://image.server/path/myimgid/info.json"
>>> print myimg.size(width=120).format('png')
http://image.server/path/myimgid/full/120,/0/default.png
Example use for parsing an IIIF image url:
>>> from piffle.image import IIIFImageClient
>>> myimg = IIIFImageClient.init_from_url('http://www.example.org/image-service/abcd1234/full/full/0/default.jpg')
>>> print myimg
http://www.example.org/image-service/abcd1234/full/full/0/default.jpg
>>> print myimg.info()
http://www.example.org/image-service/abcd1234/info.json
>>> myimg.as_dict()['size']['full']
True
>>> myimg.as_dict()['size']['exact']
False
>>> myimg.as_dict()['rotation']['degrees']
0.0
Example use for reading a IIIF manifest:
>>> from piffle.image import IIIFImageClient
>>> from piffle.presentation import IIIFPresentation
>>> manifest = IIIFPresentation.from_url('https://iiif.bodleian.ox.ac.uk/iiif/manifest/60834383-7146-41ab-bfe1-48ee97bc04be.json')
>>> manifest.label
'Bodleian Library MS. Bodl. 264'
>>> manifest.id
'https://iiif.bodleian.ox.ac.uk/iiif/manifest/60834383-7146-41ab-bfe1-48ee97bc04be.json'
>>> manifest.type
'sc:Manifest'
>>> for canvas in manifest.sequences[0].canvases[:5]:
... image_id = canvas.images[0].resource.id
... iiif_img = IIIFImageClient(*image_id.rsplit('/', 1))
... print(str(iiif_img.size(height=250)))
...
https://iiif.bodleian.ox.ac.uk/iiif/image/90701d49-5e0c-4fb5-9c7d-45af96565468/full/,250/0/default.jpg
https://iiif.bodleian.ox.ac.uk/iiif/image/e878cc78-acd3-43ca-ba6e-90a392f15891/full/,250/0/default.jpg
https://iiif.bodleian.ox.ac.uk/iiif/image/0f1ed064-a972-4215-b884-d8d658acefc5/full/,250/0/default.jpg
https://iiif.bodleian.ox.ac.uk/iiif/image/6fe52b9a-5bb7-4b5b-bbcd-ad0489fcad2a/full/,250/0/default.jpg
https://iiif.bodleian.ox.ac.uk/iiif/image/483ff8ec-347d-4070-8442-dbc15bc7b4de/full/,250/0/default.jpg
Development and Testing
This project uses git-flow branching conventions.
Install locally for development (the use of a python virtualenv is recommended):
pip install -e .
Install test dependencies:
pip install -e ".[dev]"
Run unit tests: py.test or python setup.py test
Install pre-commit hooks
Anyone who wants to contribute to this codebase should install the configured pre-commit hooks:
pre-commit install
This will configure a pre-commit hooks to automatically lint and format python code with ruff and black.
Pre-commit hooks and formatting conventions were added at version 0.5, so git blame may not reflect the true author of a given change. To make git blame more accurate, ignore formatting revisions:
git blame <FILE> --ignore-revs-file .git-blame-ignore-revs
Or configure your git to always ignore styling revision commits:
git config blame.ignoreRevsFile .git-blame-ignore-revs
Publishing python packages
A new python package is automatically built and published to PyPI using a GitHub Actions workflow when a new release is created on GitHub.
License
piffle is distributed under the Apache 2.0 License.
Contributors
- Rebecca Sutton Koeser
- Graham Hukill
- Rosie Wood
- Klaus Rettinghaus
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file piffle-0.7.0.tar.gz.
File metadata
- Download URL: piffle-0.7.0.tar.gz
- Upload date:
- Size: 38.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00f5b9e74668e6e068ee72999158d0cf49f9c75e9b02426a1f842add9253b5c3
|
|
| MD5 |
83c3f23f2050938ecf8acc6857460363
|
|
| BLAKE2b-256 |
4e1fe426ff04e030b7760228dbb442ec6b33ca2dc2986244a2ee200460465374
|
Provenance
The following attestation bundles were made for piffle-0.7.0.tar.gz:
Publisher:
python-publish.yml on Princeton-CDH/piffle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
piffle-0.7.0.tar.gz -
Subject digest:
00f5b9e74668e6e068ee72999158d0cf49f9c75e9b02426a1f842add9253b5c3 - Sigstore transparency entry: 648666047
- Sigstore integration time:
-
Permalink:
Princeton-CDH/piffle@2dab6d5e2d5f5d7151a8f8169744388a7e690304 -
Branch / Tag:
refs/tags/0.7 - Owner: https://github.com/Princeton-CDH
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@2dab6d5e2d5f5d7151a8f8169744388a7e690304 -
Trigger Event:
release
-
Statement type:
File details
Details for the file piffle-0.7.0-py3-none-any.whl.
File metadata
- Download URL: piffle-0.7.0-py3-none-any.whl
- Upload date:
- Size: 26.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64a8e087c5fedccae118a15efbb33938370fd9ac1bec01ff64dfc8f5e732718f
|
|
| MD5 |
aed0e60db87b7ac19377a7fb0ab3bde9
|
|
| BLAKE2b-256 |
2cdaa381b0150f4059274b0d3862dbc5ccd070629af1c0ab063330d27924c4f3
|
Provenance
The following attestation bundles were made for piffle-0.7.0-py3-none-any.whl:
Publisher:
python-publish.yml on Princeton-CDH/piffle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
piffle-0.7.0-py3-none-any.whl -
Subject digest:
64a8e087c5fedccae118a15efbb33938370fd9ac1bec01ff64dfc8f5e732718f - Sigstore transparency entry: 648666049
- Sigstore integration time:
-
Permalink:
Princeton-CDH/piffle@2dab6d5e2d5f5d7151a8f8169744388a7e690304 -
Branch / Tag:
refs/tags/0.7 - Owner: https://github.com/Princeton-CDH
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@2dab6d5e2d5f5d7151a8f8169744388a7e690304 -
Trigger Event:
release
-
Statement type: