Skip to main content

Python library for generating IIIF Image API urls

Project description


Python library for generating and parsing IIIF Image API URLs in an object-oriented, pythonic fashion.

Unit Test Status codecov Maintainability

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
>>> print
>>> print myimg.size(width=120).format('png')

Example use for parsing an IIIF image url:

>>> from piffle.image import IIIFImageClient
>>> myimg = IIIFImageClient.init_from_url('')
>>> print myimg
>>> print
>>> myimg.as_dict()['size']['full']
>>> myimg.as_dict()['size']['exact']
>>> myimg.as_dict()['rotation']['degrees']

Example use for reading a IIIF manifest:

>>> from piffle.image import IIIFImageClient
>>> from piffle.presentation import IIIFPresentation
>>>  manifest = IIIFPresentation.from_url('')
>>> manifest.label
'Bodleian Library MS. Bodl. 264'
>>> manifest.type
>>> for canvas in manifest.sequences[0].canvases[:5]:
...     image_id = canvas.images[0]
...     iiif_img = IIIFImageClient(*image_id.rsplit('/', 1))
...     print(str(iiif_img.size(height=250)))

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 test


To upload a tagged release to PyPI with a wheel package:

python 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

piffle-0.4.0.tar.gz (16.8 kB view hashes)

Uploaded source

Built Distribution

piffle-0.4.0-py2.py3-none-any.whl (15.9 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page