Skip to content

SilentMalachite/IIIF_Elixir_lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IIIFEx

English | 日本語


English

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.

Features

  • 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.

Installation

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"}
  ]
end

Usage

Parsing a Manifest

json = """
{
  "@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", ...}

Creating and Encoding a Manifest

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"}
  ]
end

使い方

マニフェストの読み込み (パース)

json = """
{
  "@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", ...}

License

This project is licensed under the MIT License.

About

IIIFフォーマットのElixirライブラリ

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages