Skip to main content

A Streamlit component for show IIIF viewers.

Project description

Streamlit IIIF viewer

Supported Python versions License Code style: Black

Streamlit component for viewing and interacting with manifests inside a viewer of your choice directly in your Streamlit apps.

IIIF (International Image Interoperability Framework) is a set of open standards for delivering high-quality images and metadata over the web. It is widely used in digital humanities and by cultural heritage institutions (but not only!) to share, annotate, and study digitized materials.

Currently, this components supports the following IIIF-compliant viewers :

  • Mirador (Apache-2.0 License)
  • Tify (GNU Affero General Public License v3.0)

Features

  • Display IIIF v3 manifests
  • port for document-focused viewer (e.g. Tify) and multi-window scholarly viewer (e.g. Mirador)
  • Accepts either a remote manifest URL or a local JSON object
  • Optional viewers configuration via options (language, theme, default window settings, etc.)
  • Automatically resizes within the Streamlit layout
  • Works seamlessly with Python dict IIIF manifests generated in the app

Installation

pip install streamlit-iiif-viewer

Quickstart

Display a remote manifest

import streamlit as st
from streamlit_iiif_viewer import iiif_viewer

st.title("My IIIF Viewer (remote)")

manifest_url = "https://iiif.io/api/cookbook/recipe/0009-book-1/manifest.json"

iiif_viewer(
    viewer="tify",  # or any IIIF viewers available like "mirador"
    manifest=manifest_url,
    height=800,
    options={"language": "fr"},  # optional viewer configuration
)

Display a local JSON manifest

import streamlit as st
from streamlit_iiif_viewer import iiif_viewer

st.title("My IIIF Viewer (local)")

manifest = {
    "@context": "http://iiif.io/api/presentation/3/context.json",
    "id": "https://example.org/manifest/demo",
    "type": "Manifest",
    "label": {"en": ["Local Demo"]},
    "items": [],
}

iiif_viewer(
    viewer="tify",  # or any IIIF viewers available like "mirador"
    manifest=manifest,
    height=700,
)

Viewer Configuration

You can customize the behavior of each viewer using the options argument. Full configuration guides are available in the official documentation:

[!IMPORTANT]
For now, Mirador plugins like text-overlay or image-tools are not includes.

Tify Example

options = {
    "language": "de",
    "pageLabelFormat": "P (L)",
    "pages": [2, 3],
    "pan": {"x": ".45", "y": " .6"},
    "zoom": "1.2"
}

Mirador Example

options = {
"selectedTheme":"dark",
"language":"fr",
  "workspace": {
    "type": "mosaic"
  },
  "workspaceControlPanel": {
    "enabled": true
  },
  "theme": {
    "palette": {
      "type": "light"
    }
  }
}

Development

[!NOTE] These steps are required for development purposes or to modify the component code only.

  1. Clone this repository:
git clone 
cd streamlit_iiif_viewer
  1. Install the Python dependencies:
# create a virtual environment
python3.11 -m venv .venv
# activate it
. .venv/bin/activate
# install dependencies
pip3 install -r requirements.txt
  1. Install frontend dependencies
cd streamlit_iiif_viewer/frontend
yarn install
npm install mirador # sometimes needed to explicitly install mirador (for build)
  1. Making changes

To make changes, first go to streamlit_iiif_viewer/__init__.py and make sure the variable _RELEASE is set to False. This will make the component use the local version of the frontend code, and not the built project.

Then start the dev server for frontend:

cd streamlit_iiif_viewer/frontend/
yarn dev

this start VITE server at http://localhost:5173/.

Open another terminal and run the Streamlit app to test the component:

cd streamlit_iiif_viewer/
streamlit run __init__.py

References

Specific IIIF References

This template is based on these canvas/example projects:

and streamlit documentation:

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

streamlit_iiif_viewer-0.0.1a0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

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

streamlit_iiif_viewer-0.0.1a0-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file streamlit_iiif_viewer-0.0.1a0.tar.gz.

File metadata

  • Download URL: streamlit_iiif_viewer-0.0.1a0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for streamlit_iiif_viewer-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 d4353aa04ee11522ed42ce02467f0ad83cb1124b9ab2fd42d5f16d0d012e805c
MD5 4926bcb581f3e436be552e1788b72377
BLAKE2b-256 627d05677ecaa51ea1ce5672dd75f7fa4f89de34c035014f6756ec833e5f772b

See more details on using hashes here.

File details

Details for the file streamlit_iiif_viewer-0.0.1a0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_iiif_viewer-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 36415c0c5eb64b93f2053bde72fdc1d306d057e208b184b15ba4c258218a5bde
MD5 9536dc3dfa7b2d0abc26cf368d055e6d
BLAKE2b-256 2b4c220f2b5d5e3ea15f1dd28d608fc21ce6dbb3ba74bfffeeb29a73a49c3e41

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