use of org.mycore.iiif.image.model.MCRIIIFImageProfile in project mycore by MyCoRe-Org.
the class MCRIIIFImageResource method getProfile.
public MCRIIIFImageProfile getProfile(MCRIIIFImageImpl impl) {
MCRIIIFImageProfile profile = impl.getProfile();
completeProfile(impl, profile);
return profile;
}
use of org.mycore.iiif.image.model.MCRIIIFImageProfile in project mycore by MyCoRe-Org.
the class MCRIIIFImageResource method getInfo.
@GET
@Produces(MCRIIIFMediaType.APPLICATION_LD_JSON)
@Path("{" + IDENTIFIER_PARAM + "}/info.json")
public Response getInfo(@PathParam(IMPL_PARAM) String implString, @PathParam(IDENTIFIER_PARAM) String identifier) {
try {
MCRIIIFImageImpl impl = getImpl(implString);
MCRIIIFImageInformation information = impl.getInformation(identifier);
MCRIIIFImageProfile profile = getProfile(impl);
information.profile.add(IIIF_IMAGE_API_2_LEVEL2);
information.profile.add(profile);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
return Response.ok().header("Access-Control-Allow-Origin", "*").header("Link", buildCanonicalURL(impl, identifier)).header("Profile", buildProfileURL()).entity(gson.toJson(information)).build();
} catch (MCRIIIFImageNotFoundException e) {
return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build();
} catch (MCRIIIFImageProvidingException | UnsupportedEncodingException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
} catch (MCRAccessException e) {
return Response.status(Response.Status.FORBIDDEN).entity(e.getMessage()).build();
}
}
use of org.mycore.iiif.image.model.MCRIIIFImageProfile in project mycore by MyCoRe-Org.
the class MCRIVIEWIIIFImageImpl method getProfile.
@Override
public MCRIIIFImageProfile getProfile() {
MCRIIIFImageProfile mcriiifImageProfile = new MCRIIIFImageProfile();
mcriiifImageProfile.formats = SUPPORTED_FORMATS.stream().filter(s -> !s.isEmpty()).collect(Collectors.toSet());
mcriiifImageProfile.qualities.add("color");
mcriiifImageProfile.qualities.add("bitonal");
mcriiifImageProfile.qualities.add("gray");
mcriiifImageProfile.supports.add(MCRIIIFFeatures.mirroring);
mcriiifImageProfile.supports.add(MCRIIIFFeatures.regionByPct);
mcriiifImageProfile.supports.add(MCRIIIFFeatures.regionByPx);
mcriiifImageProfile.supports.add(MCRIIIFFeatures.rotationArbitrary);
mcriiifImageProfile.supports.add(MCRIIIFFeatures.rotationBy90s);
mcriiifImageProfile.supports.add(MCRIIIFFeatures.sizeAboveFull);
mcriiifImageProfile.supports.add(MCRIIIFFeatures.sizeByWhListed);
mcriiifImageProfile.supports.add(MCRIIIFFeatures.sizeByForcedWh);
mcriiifImageProfile.supports.add(MCRIIIFFeatures.sizeByH);
mcriiifImageProfile.supports.add(MCRIIIFFeatures.sizeByPct);
mcriiifImageProfile.supports.add(MCRIIIFFeatures.sizeByW);
mcriiifImageProfile.supports.add(MCRIIIFFeatures.sizeByWh);
return mcriiifImageProfile;
}
use of org.mycore.iiif.image.model.MCRIIIFImageProfile in project mycore by MyCoRe-Org.
the class MCRMetsMods2IIIFConverter method convert.
public MCRIIIFManifest convert() {
MCRIIIFManifest manifest = new MCRIIIFManifest();
// root chapter ^= manifest metadata
LogicalStructMap logicalStructMap = (LogicalStructMap) mets.getStructMap("LOGICAL");
LogicalDiv divContainer = logicalStructMap.getDivContainer();
List<MCRIIIFMetadata> metadata = extractMedataFromLogicalDiv(mets, divContainer);
manifest.metadata = metadata;
manifest.setId(this.identifier);
PhysicalStructMap physicalStructMap = (PhysicalStructMap) mets.getStructMap("PHYSICAL");
PhysicalDiv physicalDivContainer = physicalStructMap.getDivContainer();
String id = physicalDivContainer.getId();
MCRIIIFSequence sequence = new MCRIIIFSequence(id);
List<PhysicalSubDiv> children = physicalDivContainer.getChildren();
MCRIIIFImageImpl imageImpl = MCRIIIFImageImpl.getInstance(getImageImplName());
MCRIIIFImageProfile profile = imageImpl.getProfile();
profile.setId(MCRIIIFImageUtil.getProfileLink(imageImpl));
sequence.canvases = children.stream().map(physicalSubDiv -> {
String order = physicalSubDiv.asElement().getAttributeValue("ORDER");
String orderLabel = physicalSubDiv.getOrderLabel();
String contentids = physicalSubDiv.getContentids();
String label = Stream.of(order, orderLabel, contentids).filter(o -> o != null && !o.isEmpty()).collect(Collectors.joining(" - "));
String identifier = this.physicalIdentifierMap.get(physicalSubDiv);
try {
MCRIIIFImageInformation information = imageImpl.getInformation(identifier);
MCRIIIFCanvas canvas = new MCRIIIFCanvas(identifier, label, information.width, information.height);
MCRIIIFAnnotation annotation = new MCRIIIFAnnotation(identifier, canvas);
canvas.images.add(annotation);
MCRIIIFResource resource = new MCRIIIFResource(information.getId(), MCRDCMIType.Image);
resource.setWidth(information.width);
resource.setHeight(information.height);
MCRIIIFService service = new MCRIIIFService(information.getId(), profile.getContext());
service.profile = MCRIIIFImageProfile.IIIF_PROFILE_2_0;
resource.setService(service);
annotation.setResource(resource);
return canvas;
} catch (MCRIIIFImageNotFoundException | MCRIIIFImageProvidingException e) {
throw new MCRException("Error while providing ImageInfo for " + identifier, e);
} catch (MCRAccessException e) {
LOGGER.warn("User has no access to {}", identifier);
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toList());
manifest.sequences.add(sequence);
List<MCRIIIFRange> complete = new ArrayList<>();
processDivContainer(complete, divContainer);
manifest.structures.addAll(complete);
manifest.setLabel(metadata.stream().filter(m -> m.getLabel().equals("title")).findFirst().get().getStringValue().get());
return manifest;
}
use of org.mycore.iiif.image.model.MCRIIIFImageProfile in project mycore by MyCoRe-Org.
the class MCRIIIFImageResource method getDereferencedProfile.
@GET
@Path("profile.json")
@Produces(MCRIIIFMediaType.APPLICATION_LD_JSON)
public Response getDereferencedProfile(@PathParam(IMPL_PARAM) String implStr) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
MCRIIIFImageProfile profile = getProfile(getImpl(implStr));
profile.setContext(MCRIIIFBase.API_IMAGE_2);
return Response.ok().entity(gson.toJson(profile)).build();
}
Aggregations