Mercurial > hg > digilib
changeset 1624:373b05148ab2
updated to support IIIF Image API 2.1.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 01 Jun 2017 19:08:20 +0200 |
parents | 5418b39dd49f |
children | 607e5991b8aa |
files | common/src/main/java/digilib/conf/DigilibOption.java common/src/main/java/digilib/conf/DigilibRequest.java common/src/main/java/digilib/image/ImageJobDescription.java servlet/src/main/java/digilib/servlet/ServletOps.java |
diffstat | 4 files changed, 69 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/common/src/main/java/digilib/conf/DigilibOption.java Thu Jun 01 15:06:02 2017 +0200 +++ b/common/src/main/java/digilib/conf/DigilibOption.java Thu Jun 01 19:08:20 2017 +0200 @@ -92,6 +92,10 @@ * image. */ pxarea, + /** + * select square image region from the full image (short side of the image)^2. + */ + sqarea, /** send IIIF image info (instead of image). */ info, /** send redirect to IIIF image info URI */
--- a/common/src/main/java/digilib/conf/DigilibRequest.java Thu Jun 01 15:06:02 2017 +0200 +++ b/common/src/main/java/digilib/conf/DigilibRequest.java Thu Jun 01 19:08:20 2017 +0200 @@ -472,8 +472,14 @@ // info request options.setOption(DigilibOption.info); return true; + } else if (region.equals("full")) { - // full image -- default + // full image -- digilib default + + } else if (region.equals("square")) { + // "squared" crop of full image (square of shortest side length) + options.setOption(DigilibOption.sqarea); + } else if (region.startsWith("pct:")) { // pct:x,y,w,h -- region in % of original image String[] parms = region.substring(4).split(","); @@ -523,6 +529,14 @@ options.setOption(DigilibOption.ascale); setValue("scale", 1f); + } else if (size.equals("max")) { + /* + * max -- size of original unless constrained by max image size or area + */ + options.setOption(DigilibOption.ascale); + setValue("scale", 1f); + // TODO: check with max image size + } else if (size.startsWith("pct:")) { /* * pct:n -- n% size of original
--- a/common/src/main/java/digilib/image/ImageJobDescription.java Thu Jun 01 15:06:02 2017 +0200 +++ b/common/src/main/java/digilib/image/ImageJobDescription.java Thu Jun 01 19:08:20 2017 +0200 @@ -897,6 +897,17 @@ // area in absolute pixels - convert to relative hiresSize = getHiresSize(); paramWW = paramWW / hiresSize.getWidth(); + } else if (hasOption(DigilibOption.sqarea)) { + // square full size area + hiresSize = getHiresSize(); + float aspect = hiresSize.getAspect(); + if (aspect < 1) { + // portrait + paramWW = 1f; + } else { + // landscape + paramWW = 1f / aspect; + } } } return paramWW; @@ -918,6 +929,17 @@ // area in absolute pixels - convert to relative hiresSize = getHiresSize(); paramWH = paramWH / hiresSize.getHeight(); + } else if (hasOption(DigilibOption.sqarea)) { + // square full size area + hiresSize = getHiresSize(); + float aspect = hiresSize.getAspect(); + if (aspect < 1) { + // portrait + paramWH = aspect; + } else { + // landscape + paramWH = 1f; + } } } return paramWH; @@ -939,6 +961,17 @@ // area in absolute pixels - convert to relative ImageSize imgSize = getHiresSize(); paramWX = paramWX / imgSize.getWidth(); + } else if (hasOption(DigilibOption.sqarea)) { + // square full size area + hiresSize = getHiresSize(); + float aspect = hiresSize.getAspect(); + if (aspect < 1) { + // portrait + paramWX = 0f; + } else { + // landscape + paramWX = (1f - (1f / aspect)) / 2f; + } } } return paramWX; @@ -960,6 +993,17 @@ // area in absolute pixels - convert to relative ImageSize imgSize = getHiresSize(); paramWY = paramWY / imgSize.getHeight(); + } else if (hasOption(DigilibOption.sqarea)) { + // square full size area + hiresSize = getHiresSize(); + float aspect = hiresSize.getAspect(); + if (aspect < 1) { + // portrait + paramWY = (1f - aspect) / 2f; + } else { + // landscape + paramWY = 0f; + } } } return paramWY;
--- a/servlet/src/main/java/digilib/servlet/ServletOps.java Thu Jun 01 15:06:02 2017 +0200 +++ b/servlet/src/main/java/digilib/servlet/ServletOps.java Thu Jun 01 19:08:20 2017 +0200 @@ -503,7 +503,12 @@ writer.println(" {"); writer.println(" \"formats\" : [\"jpg\", \"png\"],"); writer.println(" \"qualities\" : [\"color\", \"gray\"],"); - writer.println(" \"supports\" : [\"mirroring\", \"rotationArbitrary\", \"sizeAboveFull\"]"); + if (dlConfig.getAsInt("max-image-size") > 0) { + writer.println(" \"maxArea\" : " + dlConfig.getAsInt("max-image-size") + ","); + } + writer.println(" \"supports\" : [" + + "\"mirroring\", \"rotationArbitrary\", \"sizeAboveFull\", \"regionSquare\"" + + "]"); writer.println(" }]"); // add sizes of prescaled images int numImgs = imageSet.size();