IIIFEx is an Elixir library for working with the IIIF (International Image Interoperability Framework) Presentation API 3.0. It provides functionality to parse JSON manifests into Elixir structs and encode structs back into IIIF-compliant JSON.
- Parse: Converts IIIF JSON strings into nested Elixir structs (Manifest, Canvas, AnnotationPage, etc.).
- Encode: Generates compliant JSON-LD from Elixir structs.
- Data Model: Full support for core IIIF Presentation API 3.0 resources.
If available in Hex, the package can be installed by adding lllf_elixir to your list of dependencies in mix.exs:
def deps do
[
{:lllf_elixir, "~> 0.1.0"}
]
endjson = """
{
"@context": "http://iiif.io/api/presentation/3/context.json",
"id": "https://example.com/manifest/1",
"type": "Manifest",
"label": { "en": [ "My Manifest" ] },
"items": []
}
"""
{:ok, manifest} = IIIFEx.parse(json)
# => %IIIFEx.Presentation.Manifest{id: "https://example.com/manifest/1", ...}alias IIIFEx.Presentation.{Manifest, Canvas}
# Create a new Manifest
manifest = IIIFEx.new_manifest("https://example.com/manifest/1", "My Manifest")
# Add a Canvas (Manual construction example)
canvas = IIIFEx.Presentation.Canvas.new("https://example.com/canvas/1", "Page 1", 1000, 800)
manifest = %{manifest | items: [canvas]}
# Convert to JSON
{:ok, json} = IIIFEx.to_json(manifest)
# => {"@context": "...", "type": "Manifest", ...}IIIFEx は、IIIF (International Image Interoperability Framework) Presentation API 3.0 を扱うための Elixir ライブラリです。JSON マニフェストを Elixir の構造体にパースしたり、構造体から IIIF 準拠の JSON を生成したりする機能を提供します。
- パース (Parse): IIIF JSON 文字列をネストされた Elixir 構造体 (Manifest, Canvas, AnnotationPage など) に変換します。
- エンコード (Encode): Elixir 構造体から準拠した JSON-LD を生成します。
- データモデル: IIIF Presentation API 3.0 の主要なリソースをサポートしています。
mix.exs の依存関係に lllf_elixir を追加してください。
def deps do
[
{:lllf_elixir, "~> 0.1.0"}
]
endjson = """
{
"@context": "http://iiif.io/api/presentation/3/context.json",
"id": "https://example.com/manifest/1",
"type": "Manifest",
"label": { "ja": [ "私のマニフェスト" ] },
"items": []
}
"""
{:ok, manifest} = IIIFEx.parse(json)
# => %IIIFEx.Presentation.Manifest{id: "https://example.com/manifest/1", ...}alias IIIFEx.Presentation.{Manifest, Canvas}
# 新しいマニフェストの作成
manifest = IIIFEx.new_manifest("https://example.com/manifest/1", "My Manifest")
# Canvas の追加 (手動での構築例)
canvas = IIIFEx.Presentation.Canvas.new("https://example.com/canvas/1", "Page 1", 1000, 800)
manifest = %{manifest | items: [canvas]}
# JSON への変換
{:ok, json} = IIIFEx.to_json(manifest)
# => {"@context": "...", "type": "Manifest", ...}This project is licensed under the MIT License.