Filesystem Spec (fsspec) plugin for IIIF (International Image Interoperability Framework) resources
Project description
iiif-fsspec
iiif-fsspec is a read-only fsspec plugin for
IIIF (International Image Interoperability Framework) resources.
It exposes a IIIF manifest as a directory and canvas images as files.
Two path styles are accepted interchangeably:
| Style | Example |
|---|---|
iiif:// (registered fsspec protocol) |
iiif://example.org/iiif/manifest.json |
https:// / http:// (raw manifest URL) |
https://example.org/iiif/manifest.json |
Returned paths always preserve the style of the caller's input:
iiif://example.org/iiif/manifest.json→ directoryiiif://example.org/iiif/manifest.json/canvas-one.jpg→ filehttps://example.org/iiif/manifest.json→ directoryhttps://example.org/iiif/manifest.json/canvas-one.jpg→ file
The plugin supports both IIIF Presentation API v2 and v3 manifests with automatic version detection.
Overview
This package lets data-access systems use IIIF manifests through the standard fsspec filesystem
interface. That means you can call ls, info, open, and cat_file on IIIF URLs and treat
them like regular filesystem paths.
Current scope:
- Read-only operations
- Manifest listing to canvas file entries
- Collection listing to stateless child paths
- Full image reads and range reads
- In-memory manifest caching
When a collection is listed, child entries keep a resolvable stateless path in name, preserve
the human-friendly label in iiif_label, and keep the IIIF identifier in iiif_id. The path
remains self-contained so a value returned from one filesystem instance can be opened or listed
from a fresh instance without prior cache warm-up. Malformed stateless collection paths raise
InvalidPathError.
Installation
Using uv:
uv add iiif-fsspec
Using pip:
pip install iiif-fsspec
Quick Start
import fsspec
fs = fsspec.filesystem("iiif")
# Both https:// and iiif:// paths are accepted; returned names mirror the input style.
# List canvases using a raw manifest URL
entries = fs.ls("https://example.org/iiif/manifest.json", detail=True)
# Read a canvas image
with fs.open("https://example.org/iiif/manifest.json/canvas-one.jpg", "rb") as handle:
image_bytes = handle.read()
Usage Examples
Python API
from iiif_fsspec import IIIFFileSystem
fs = IIIFFileSystem()
# Using a raw https:// manifest URL
paths = fs.ls("https://example.org/iiif/manifest.json")
print(paths) # ['https://example.org/iiif/manifest.json/canvas-one.jpg', ...]
chunk = fs.cat_file("https://example.org/iiif/manifest.json/canvas-one.jpg", start=0, end=1024)
print(len(chunk))
fsspec.open Integration
import fsspec
# Use the iiif:// scheme with fsspec.open (routes to IIIFFileSystem via entry-point)
with fsspec.open("iiif://example.org/iiif/manifest.json/canvas-one.jpg", "rb") as handle:
first_kb = handle.read(1024)
# Or instantiate IIIFFileSystem directly with a plain https:// URL
from iiif_fsspec import IIIFFileSystem
fs = IIIFFileSystem()
with fs.open("https://example.org/iiif/manifest.json/canvas-one.jpg", "rb") as handle:
first_kb = handle.read(1024)
Real-World Examples
The examples folder includes runnable scripts that browse a real IIIF manifest:
https://api.irht.cnrs.fr/ark:/63955/fbkub82u5bw7/manifest.json
From the repository root:
uv run python examples/browse_manifest.py
uv run python examples/read_first_canvas.py
uv run python examples/download_canvas.py --index 1 --output /tmp/canvas-1.jpg
To target a different manifest:
uv run python examples/browse_manifest.py --manifest-url https://example.org/iiif/manifest.json
Supported IIIF Versions
- IIIF Presentation API v2
- IIIF Presentation API v3
Version detection uses manifest metadata (@context, type, and @type) and dispatches to the
appropriate parser.
Security Notes
iiif-fsspec fetches manifests, image resources, and info.json endpoints from remote servers.
Treat manifest content as a source of outbound network locations, not just metadata.
Current network policy:
- Only
httpandhttpsresource URLs are accepted. - Redirects are followed only through an explicit policy in the HTTP client.
http -> httpsredirects are allowed.https -> httpredirects are rejected.- Non-HTTP(S) redirect targets are rejected.
Operational implications:
- A manifest can point to image or IIIF service URLs on arbitrary hosts.
- Redirects can move a request to a different host, as long as the redirect stays within the allowed transport policy above.
- This package is intended for public IIIF resources and does not add host allowlisting or SSRF protections on top of normal URL validation.
If you process manifests from untrusted sources or run this library in a sensitive environment, consider wrapping it with your own outbound network controls, such as host allowlists, egress filtering, or sandboxing.
Architecture
Main modules:
src/iiif_fsspec/filesystem.py: fsspec filesystem implementationsrc/iiif_fsspec/iiif_file.py: read-only file object for image accesssrc/iiif_fsspec/client.py: async HTTP client wrapper (httpx)src/iiif_fsspec/manifest.py: IIIF v2/v3 manifest parsingsrc/iiif_fsspec/path.py: fsspec path <-> IIIF URL resolutionsrc/iiif_fsspec/types.py: dataclasses and parser protocolsrc/iiif_fsspec/exceptions.py: package exception hierarchy
Development
Install dependencies:
uv sync --dev
Run checks:
uv run ruff check src/ tests/
uv run ruff format --check src/ tests/
uv run mypy src/ tests/
uv run pytest --cov=iiif_fsspec --cov-report=term-missing
# Run live-network integration tests (opt-in, requires network access)
uv run pytest -m integration -v
CI test strategy:
- Default CI runs fast deterministic tests and excludes live integration tests.
- A separate
Integrationworkflow runs real-network tests against:https://iiif.io/api/cookbook/recipe/0001-mvm-image/manifest.json. - The integration workflow is triggered manually (
workflow_dispatch) and on a low-frequency schedule.
Pre-commit hooks are configured in .pre-commit-config.yaml.
Release
This project publishes to TestPyPI and PyPI from tags matching v* via
GitHub Actions trusted publishing (OIDC).
Release steps:
# 1) Bump version in both files:
# - pyproject.toml
# - src/iiif_fsspec/__init__.py
# 2) Run checks
uv run ruff check src/ tests/
uv run mypy src/ tests/
uv run pytest
# 3) Commit and push
git add pyproject.toml src/iiif_fsspec/__init__.py
git commit -m "Release vX.Y.Z"
git push
# 4) Create and push a tag (final or prerelease)
git tag vX.Y.Z
git push origin vX.Y.Z
License
MIT. See LICENSE.
Acknowledgments
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 iiif_fsspec-0.1.0.tar.gz.
File metadata
- Download URL: iiif_fsspec-0.1.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f30799bdccb1d37c96865ce5b87514dfe7ac3223c5988a088df2c114b6a61946
|
|
| MD5 |
d1501d418711eacf03f86641e6f88c6f
|
|
| BLAKE2b-256 |
58ba371386961fc5780f77b8ac98c7461a1ffdfe56b61f5ffe7cb2a9c29cf51c
|
Provenance
The following attestation bundles were made for iiif_fsspec-0.1.0.tar.gz:
Publisher:
publish.yml on davelopez/iiif-fsspec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iiif_fsspec-0.1.0.tar.gz -
Subject digest:
f30799bdccb1d37c96865ce5b87514dfe7ac3223c5988a088df2c114b6a61946 - Sigstore transparency entry: 1175668698
- Sigstore integration time:
-
Permalink:
davelopez/iiif-fsspec@670d1d8524498afb4f1d51d0d96402ebad3f7f3b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/davelopez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@670d1d8524498afb4f1d51d0d96402ebad3f7f3b -
Trigger Event:
push
-
Statement type:
File details
Details for the file iiif_fsspec-0.1.0-py3-none-any.whl.
File metadata
- Download URL: iiif_fsspec-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.0 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 |
9a8a8e7ab4ecf1c61699f00ed72b19ccd54ecc8d2798e606147fb13502f515ca
|
|
| MD5 |
e9df1ed2b6ca23b242b6c2d9e58a2ccc
|
|
| BLAKE2b-256 |
e4475fb2dbf132554c3d85f001101935dd4e59c2c2e99bf9478d7eb107bf122b
|
Provenance
The following attestation bundles were made for iiif_fsspec-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on davelopez/iiif-fsspec
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iiif_fsspec-0.1.0-py3-none-any.whl -
Subject digest:
9a8a8e7ab4ecf1c61699f00ed72b19ccd54ecc8d2798e606147fb13502f515ca - Sigstore transparency entry: 1175668745
- Sigstore integration time:
-
Permalink:
davelopez/iiif-fsspec@670d1d8524498afb4f1d51d0d96402ebad3f7f3b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/davelopez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@670d1d8524498afb4f1d51d0d96402ebad3f7f3b -
Trigger Event:
push
-
Statement type: