Python library for generating IIIF Image API urls
Project description
piffle
Python library for generating and parsing IIIF Image API URLs in an object-oriented, pythonic fashion.
Piffle is tested on Python 3.6-3.8.
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 virtualenv is recommended):
pip install -e .
Install test dependencies:
pip install -e ".[test]"
Run unit tests: py.test
or python setup.py test
Publishing
To upload a tagged release to PyPI with a wheel package:
python setup.py sdist bdist_wheel upload
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
Built Distribution
File details
Details for the file piffle-0.4.0.tar.gz
.
File metadata
- Download URL: piffle-0.4.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.2.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f69e89ec1cd81e13beeb885e4a7d9d65d5a6f0da9ca216536a0590b63d2c98ac |
|
MD5 | 9232e967c49d22114d246105e3a1a98b |
|
BLAKE2b-256 | 82e3a730e7150a5de98d816362bed430b30a9676f1d9d816334486d8018603b7 |
File details
Details for the file piffle-0.4.0-py2.py3-none-any.whl
.
File metadata
- Download URL: piffle-0.4.0-py2.py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.2.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d6f8a209d6cce6d09d86bfec45c384cf048fe512389962a0b8537cc561f4782 |
|
MD5 | b560e43e560ccf8cfcc5f3c9f05a55b2 |
|
BLAKE2b-256 | b96466330e6b5fd269f47fb2a4ea95b3be06bc846d391160b6a10cb8bc480987 |