Mercurial > hg > digilib
changeset 1588:e9ad60c4fb0c
added new mo=crop to scale to fill the full destination size by scaling for the shorter side and cutting off on the longer side.
has small rounding issues with destination size.
author | robcast |
---|---|
date | Wed, 08 Feb 2017 13:26:07 +0100 |
parents | 02446ff6948b |
children | 6892f39c1fdb |
files | common/src/main/java/digilib/conf/DigilibConfiguration.java common/src/main/java/digilib/image/ImageJobDescription.java |
diffstat | 2 files changed, 36 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/common/src/main/java/digilib/conf/DigilibConfiguration.java Sun Nov 13 18:52:47 2016 +0100 +++ b/common/src/main/java/digilib/conf/DigilibConfiguration.java Wed Feb 08 13:26:07 2017 +0100 @@ -57,7 +57,7 @@ /** digilib version */ public static String getClassVersion() { - return "2.4.0a"; + return "2.4.1a"; } /* non-static getVersion for Java inheritance */
--- a/common/src/main/java/digilib/image/ImageJobDescription.java Sun Nov 13 18:52:47 2016 +0100 +++ b/common/src/main/java/digilib/image/ImageJobDescription.java Wed Feb 08 13:26:07 2017 +0100 @@ -184,7 +184,7 @@ /** * Creates new ImageJobDescription by merging Parameters from a - * DigilibRequest and adding an ImageSEt. + * DigilibRequest and adding an ImageSet. * * @param dlReq * @param imgs @@ -322,21 +322,50 @@ } else if (scaleY == 0) { // dh undefined scaleY = scaleX; + } else if (hasOption("crop")) { + // use the bigger factor to get fill-the-box + if (scaleX > scaleY) { + scaleY = scaleX; + // crop mode uses whole destination rect + long croppedAreaHeight = (long) (getDh() / scaleY); + if (areaHeight > croppedAreaHeight) { + // center cropped area + areaY += (areaHeight - croppedAreaHeight) / 2; + } + areaHeight = croppedAreaHeight; + } else { + scaleX = scaleY; + // crop mode uses whole destination rect + long croppedAreaWidth = (long) (getDw() / scaleX); + if (areaWidth > croppedAreaWidth) { + // center cropped area + areaX += (areaWidth - croppedAreaWidth) / 2; + } + areaWidth = croppedAreaWidth; + } } else { // use the smaller factor to get fit-in-box if (scaleX > scaleY) { scaleX = scaleY; if (hasOption("fill")) { // fill mode uses whole destination rect - // TODO: should we center, clip or shift the area? - areaWidth = (long) (getDw() / scaleX); + long filledAreaWidth = (long) (getDw() / scaleX); + if (filledAreaWidth > areaWidth) { + // center filled area + areaX -= (filledAreaWidth - areaWidth) / 2; + } + areaWidth = filledAreaWidth; } } else { scaleY = scaleX; if (hasOption("fill")) { // fill mode uses whole destination rect - // TODO: should we center, clip or shift the area? - areaHeight = (long) (getDh() / scaleY); + long filledAreaHeight = (long) (getDh() / scaleY); + if (filledAreaHeight > areaHeight) { + // center filled area + areaY -= (filledAreaHeight - areaHeight) / 2; + } + areaHeight = filledAreaHeight; } } } @@ -691,7 +720,7 @@ } /** - * Do not scale, just crop. + * Do not scale, just crop original resolution. * * @return */