dbmdz / iiif-apis Goto Github PK
View Code? Open in Web Editor NEWJava Domain Models for all IIIF APIs
License: MIT License
Java Domain Models for all IIIF APIs
License: MIT License
Hi,
According to http://iiif.io/api/presentation/2.1/#image-resources, "format" for the image resource should be something like "image/jpeg", however, it is currently printing out MimeType in its entirety:
"format": {"primaryType": "image","subType": "jpeg","extensions": ["jpg","jpeg","jpe"],"typeName": "image/jpeg"}
Would it still be compliant if it prints more than just the value of "typeName"?
I'm trying to add a rotated image to a canvas in my manifests, using this example from the spec, so that in the end I get a canvas like
{
"@id": "https://iiifpres-dev.bdrc.io/v:bdr:I4CZ75258/canvas/I4CZ752580003.jpg",
"@type": "sc:Canvas",
"label": "1a",
"images": [
{
"@type": "oa:Annotation",
"motivation": "sc:painting",
"resource": {
"@id": "https://iiif-dev.bdrc.io/bdr:I4CZ75258::I4CZ752580003.jpg/full/max/180/default.jpg",
"@type": "oa:SpecificResource",
"full": {
"@id": "https://iiif-dev.bdrc.io/bdr:I4CZ75258::I4CZ752580003.jpg/full/max/0/default.jpg",
"@type": "dctypes:Image",
"service": {
"@context": "http://iiif.io/api/image/2/context.json",
"@id": "https://iiif-dev.bdrc.io/bdr:I4CZ75258::I4CZ752580003.jpg",
"width": 2550,
"height": 879,
"profile": "http://iiif.io/api/image/2/level0.json",
"protocol": "http://iiif.io/api/image"
},
"format": "image/jpeg",
"width": 2550,
"height": 879
},
"selector": {
"@context": "http://iiif.io/api/annex/openannotation/context.json",
"@type": "iiif:ImageApiSelector",
"rotation": "180"
}
},
"on": "https://iiifpres-dev.bdrc.io/v:bdr:I4CZ75258/canvas/I4CZ752580003.jpg"
}
],
"width": 2550,
"height": 879
}
(see this manifest). WIth the current API, I can build the whole annotation (using this example), but then I'm stuck as I can't add it in the canvas object, because my Annotation
is not an ImageContent
.
Is it possible to tweak things a bit in the object model so that the annotation can be added in the canvas?
related: ProjectMirador/mirador#2962
Hi, the documentation link in the README seems to 404. It points to http://javadoc.io/doc/de.digitalcollections.iiif/iiif-apis but that doesn't return anything.
Method addCanvas
of class Range
fails with message:
Exception in thread "main" java.lang.IllegalArgumentException: Member resource must only have an identifier and no other field. Use add<Resource>(URI first, URI... rest) for convenience.
at de.digitalcollections.iiif.model.sharedcanvas.Range.checkIdOnly(Range.java:98)
at de.digitalcollections.iiif.model.sharedcanvas.Range.addCanvas(Range.java:113)
It can be reproduced with:
import de.digitalcollections.iiif.model.sharedcanvas.Range;
class Test {
public static void main(String[] args) {
Range range = new Range("http://test/foo");
range.addCanvas("http://test/baz");
}
}
The cause is in method getCompleteness
of ModelUtilities
: the method getClass
of Object
is not filtered.
It could be replaced by:
public static Completeness getCompleteness(Object res, Class<?> type) {
Set<Method> getters =
ReflectionUtils.getAllMethods(
type, ReflectionUtils.withModifier(Modifier.PUBLIC), ReflectionUtils.withPrefix("get"));
Set<String> gettersWithValues =
getters.stream()
.filter(g -> !g.getName().equals("getClass"))
.filter(g -> g.getAnnotation(JsonIgnore.class) == null) // Only JSON-serializable fields
.filter(g -> returnsValue(g, res))
.map(Method::getName)
.collect(Collectors.toSet());
if (gettersWithValues.isEmpty()) {
return Completeness.EMPTY;
} else if (containsOnly(gettersWithValues, "getType", "getIdentifier")) {
return Completeness.ID_AND_TYPE;
} else if (containsOnly(gettersWithValues, "getType", "getIdentifier", "getLabels")) {
return Completeness.ID_AND_TYPE_AND_LABEL;
} else if (containsOnly(gettersWithValues, "getIdentifier")) {
return Completeness.ID_ONLY;
} else {
return Completeness.COMPLEX;
}
}
The API should support multiple selectors for a given resource.
According to the specification it's legal to include a string a license
although not recommended. This isn't supported.
Example manifest:
https://manifests.sub.uni-goettingen.de/iiif/presentation/DE-611-HS-3461927/manifest?version=r3rpa
Both IIIF Image and IIIF Presentation APIs have their BETA 3.0 versions published (currently November 2019) and the only thing holding them back from being officially released are open source implementations of each version as per their editorial standards. As version 3 opens up the ability to create manifests for audio and video we are eager to start implementing new manifests
https://iiif.io/api/image/3.0/
https://iiif.io/api/presentation/3.0/
Manifests created should pass the official IIIF v3.0 manifest validators:
https://iiif.io/api/image/validator/
https://iiif.io/api/presentation/validator/service/
Edited to add link to change logs
https://iiif.io/api/presentation/3.0/change-log/
https://iiif.io/api/image/3.0/change-log/
A common issue are requests that either request a generally invalid image region (e.g. height or width of 0) or would result in a in a invalid image region after scaling. This could be checked within the ImageApiSelector to handle most of the cases at a central place.
What I'm trying to do boils down to:
public void testInfiniteLoop() throws JsonGenerationException, JsonMappingException, IOException {
String uribase = "http://example.com/";
final Canvas canvas = new Canvas(uribase+"-canvas");
Annotation annotation = new Annotation(uribase+"-ann0", Motivation.PAINTING);
annotation.setOn(canvas);
AnnotationList all = new AnnotationList(uribase+"-anlist0");
all.addResource(annotation);
canvas.addOtherContent(all);
new IiifObjectMapper().writerWithDefaultPrettyPrinter().writeValue(System.out, canvas);
}
which creates an infinite look in the serialization, because the annotation refers to the canvas in the .setOn()
and the canvas refers to the annotation in the .addOtherContent()
. There are probably better ways to avoid that, but one easy way out of this kind of issue would be to add a .setOn()
function that takes a String
as an argument instead of a resource
Problem
The mime.types
file is placed at the root level of the resources.
So, to load it we will use the class loader passing the file name (without any package) - as you can see here https://github.com/dbmdz/iif-apis/blob/main/src/main/java/de/digitalcollections/iif/model/MimeType.java#L45.
This means that, depending on the class loader implementation, if you have multiple jars containing the same mime.type
file at the root level, you may load the wrong file from another library.
Resolution
A simple solution could be to move the mime.types
to a specific package.
Then, to load the resource, we can specify the package (for example de/digitalcollections/iiif/utils/mime.types
).
As we can see in presentation specification, we can give multiple contexts (to link default and custom contexts).
e.g
{
"@context": [
"http://iiif.io/api/presentation/2/context.json",
"http://example.org/extension/context.json"
]
}
It seems that the context is only a string but it would be great if it was a collection 🙂
In the Annotation.java class the "on" variable is defined as a Resource. This renders an invalid presentation manifest. This is a correct manifest:
"on": "https://some.url/iiif/dcterms/672/canvas/c0"
whereas this code deserializes to
"on": { "@id": "https://some.url/iiif/vads-demo2/2/canvas/c0", "@type": "sc:Canvas" }
If you view the IIIF presentation specs, all the examples use the first example.
The repository is currently not ready for compilation with openjdk11
:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:3.0.1:jar (attach-javadocs) on project iiif-apis: MavenReportException: Error while generating Javadoc:
[ERROR] Exit code: 1 - javadoc: warning - The old Doclet and Taglet APIs in the packages
[ERROR] com.sun.javadoc, com.sun.tools.doclets and their implementations
[ERROR] are planned to be removed in a future JDK release. These
[ERROR] components have been superseded by the new APIs in jdk.javadoc.doclet.
[ERROR] Users are strongly recommended to migrate to the new APIs.
[ERROR] javadoc: error - invalid flag: -author
The ch.raffael.mddoclet.MarkdownDoclet
needs a fix, see also this issue.
See this manifest:
"attribution" : {
"de" : [
"Georg-August Universität Göttingen"
],
"en" : [
"Goobi viewer"
]
}
The IiifObjectMapper
fails with:
com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.NullPointerException) (through reference chain: de.digitalcollections.iiif.model.sharedcanvas.Manifest["attribution"])
This certainly related to different minor versions of the IIIF Presentation API 2.x.
When producing moderately small IIIF manfests (monograph with about 35 pages/images) using REST controller in Spring, added latency about 15ms can be noticed in process of serializing using Jackson. At first I thought that this was Jackson being slow... but slowdown can be traced down to custom serializer ResourceSerializer namely line 110 where replacing gen.writeObject with gen.writeString fixes most of the latency. This can be blatantly seen in Chrome response view as blue tail of time to download content.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.