DigitalCollections: IIIF API Library

Java library implementing all available IIIF APIs

License

License

GroupId

GroupId

de.digitalcollections.iiif
ArtifactId

ArtifactId

iiif-apis
Last Version

Last Version

0.3.9
Release Date

Release Date

Type

Type

jar
Description

Description

DigitalCollections: IIIF API Library
Java library implementing all available IIIF APIs
Project URL

Project URL

https://github.com/dbmdz/iiif-apis
Source Code Management

Source Code Management

https://github.com/dbmdz/iiif-apis

Download iiif-apis

How to add to project

<!-- https://jarcasting.com/artifacts/de.digitalcollections.iiif/iiif-apis/ -->
<dependency>
    <groupId>de.digitalcollections.iiif</groupId>
    <artifactId>iiif-apis</artifactId>
    <version>0.3.9</version>
</dependency>
// https://jarcasting.com/artifacts/de.digitalcollections.iiif/iiif-apis/
implementation 'de.digitalcollections.iiif:iiif-apis:0.3.9'
// https://jarcasting.com/artifacts/de.digitalcollections.iiif/iiif-apis/
implementation ("de.digitalcollections.iiif:iiif-apis:0.3.9")
'de.digitalcollections.iiif:iiif-apis:jar:0.3.9'
<dependency org="de.digitalcollections.iiif" name="iiif-apis" rev="0.3.9">
  <artifact name="iiif-apis" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.digitalcollections.iiif', module='iiif-apis', version='0.3.9')
)
libraryDependencies += "de.digitalcollections.iiif" % "iiif-apis" % "0.3.9"
[de.digitalcollections.iiif/iiif-apis "0.3.9"]

Dependencies

compile (8)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-annotations jar 2.11.3
com.fasterxml.jackson.core : jackson-databind jar 2.11.3
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar 2.11.3
com.fasterxml.jackson.module : jackson-module-parameter-names jar 2.11.3
com.google.guava : guava jar 30.0-jre
de.grundid.opendatalab : geojson-jackson jar 1.14
org.dmfs : rfc3986-uri jar 0.8.1
org.reflections : reflections jar 0.9.12

test (5)

Group / Artifact Type Version
com.revinate : assertj-json jar 1.1.0
org.assertj : assertj-core jar 3.18.1
org.junit.jupiter : junit-jupiter-api jar 5.7.0
org.junit.jupiter : junit-jupiter-engine jar 5.7.0
org.skyscreamer : jsonassert jar 1.5.0

Project Modules

There are no modules declared in this project.

iiif-apis

Image API 2.1.1 compliant Presentation API 2.1.1 compliant Authentication API 1.0 compliant Search API 1.0 compliant

Javadocs License GitHub release Maven Central

This module contains model classes for all currently available IIIF API entities, namely for the Presentation, Image, Content Search and Authentication APIs, as well as the additional services defined in the Service Annex. It also includes all the necessary components to parse and create valid JSON-LD representations of these entities, using Jackson.

The library contains a comprehensive test suite for all entities, based on all of the examples provided in the IIIF specifications. Therefore, it should be able to parse and create any IIIF documents that are compliant with the official specifications. If you find that you cannot parse a IIIF entity that you believe to be correct, please submit an issue including a link to the JSON-LD representation of the entity. Likewise, if you find that you cannot express a certain IIIF construct with the Java API, let us know.

It is intended to replace both iiif-presentation-api and iiif-image-api once it is stable enough, with the non-model parts of these libraries being moved into hymir.

Usage

To use the module, first add it to your project's Maven or Gradle configuration:

<dependency>
  <groupId>de.digitalcollections.iiif</groupId>
  <artifactId>iiif-apis</artifactId>
  <version>0.3.8</version>
</dependency>
dependencies {
    compile 'de.digitalcollections.iiif.iiif-apis:0.3.8'
}

For both reading and writing IIIF JSON-LD documents, it is neccessary to instantiate the Jackson object mapper:

import de.digitalcollections.iiif.model.jackson.IiifObjectMapper;

ObjectMapper iiifMapper = new IiifObjectMapper();

The mapper can then be used to read IIIF JSON-LD documents into their corresponding Java object:

import de.digitalcollections.iiif.model.sharedcanvas.Manifest;

// Reading a manifest
Manifest manifest = iiifMapper.readValue(
    "http://iiif.biblissima.fr/manifests/ark:/12148/btv1b8304502m/manifest.json",
    Manifest.class);

// Reading an annotation list
AnnotationList annoList = iiifMapper.readValue(
    "http://dams.llgc.org.uk/iiif/4342443/annotation/list/ART8.json",
    AnnotationList.class);

To create your own IIIF entities, just model them using the available classes and use the object mapper to obtain their JSON-LD representation:

import de.digitalcollections.iiif.model.sharedcanvas.Canvas;
import de.digitalcollections.iiif.model.ImageContent;
import de.digitalcollections.iiif.model.image.ImageApiProfile;
import de.digitalcollections.iiif.model.image.ImageService;
import de.digitalcollections.iiif.model.OtherContent;
import de.digitalcollections.iiif.model.search.ContentSearchService;
import de.digitalcollections.iiif.model.PropertyValue;

import java.util.Locale;


Canvas canvas = new Canvas("http://some.uri");
canvas.addLabel("A label");
canvas.addDescription("This is a slightly longer text about this canvas.");
canvas.setWidth(800);
canvas.setHeight(600);

// Image
canvas.addIIIFImage("http://some.uri/iiif/foo", ImageApiProfile.LEVEL_ONE);

// Thumbnail
ImageContent thumbnail = new ImageContent("http://some.uri/iiif/foo/full/250,/0/default.jpg");
thumbnail.addService(new ImageService("http://some.uri/iiif/foo", ImageApiProfile.LEVEL_ONE));
canvas.addThumbnail(thumbnail);

// Other Content
canvas.addSeeAlso(new OtherContent("http://some.uri/ocr/foo.hocr", "text/html"));

// Search Service
ContentSearchService searchService = new ContentSearchService("http://some.uri/search/foo");
searchService.addAutocompleteService("http://some.uri/autocomplete/foo");
canvas.addService(searchService);

// Metadata
canvas.addMetadata("Author", "Ignatius Jacques Reilly");
canvas.addMetadata("Location", "New Orleans");
PropertyValue key = new PropertyValue();
key.addValue(Locale.ENGLISH, "Key");
key.addValue(Locale.GERMAN, "Schlüssel");
key.addValue(Locale.CHINESE, "");
PropertyValue value = new PropertyValue();
value.addValue(Locale.ENGLISH, "A value", "Another value");
value.addValue(Locale.GERMAN, "Ein Wert", "Noch ein Wert");
value.addValue(Locale.CHINESE, "", "另值");
canvas.addMetadata(new MetadataEntry(key, value));

// Other stuff
canvas.addViewingHint(ViewingHint.NON_PAGED);

// Licensing/Attribution
canvas.addLicense("http://rightsstatements.org/vocab/NoC-NC/1.0/");
canvas.addAttribution("Some fictional institution");
canvas.addLogo("http://some.uri/logo.jpg");
canvas.addLogo(new ImageContent(new ImageService(
    "http://some.uri/iiif/logo", ImageApiProfile.LEVEL_ONE)));

String json = iiifMapper.writerWithDefaultPrettyPrinter().writeValueAsString(canvas);

For more information on how to use the API, consult the API documentation and the comprehensive test suite. Since the large majority of the tests are based on the examples from the specifications, they should be very easy to follow along.

de.digitalcollections.iiif

Open Source at the Bayerische Staatsbibliothek

...from the MDZ Digital Library team at the Bavarian State Library

Versions

Version
0.3.9
0.3.8
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.0