Commit 96324d29 authored by Julien Lerouge's avatar Julien Lerouge

Corrected a bug with desired output width/height in request

parent dcc14f49
......@@ -26,25 +26,17 @@
</plugins>
</pluginManagement>
</build>
<repositories>
<!-- This provides Stian Soiland-Reyes re-packaged version of JAI-ImageIO -->
<repository>
<releases />
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>mygrid-repository</id>
<name>myGrid Repository</name>
<url>http://www.mygrid.org.uk/maven/repository</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.java.dev.jai-imageio</groupId>
<artifactId>jai-imageio-core-standalone</artifactId>
<version>1.2-pre-dr-b04-2011-07-04</version>
</dependency>
<dependency>
<groupId>com.github.jai-imageio</groupId>
<artifactId>jai-imageio-core</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.github.jai-imageio</groupId>
<artifactId>jai-imageio-jpeg2000</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.devlib.schmidt</groupId>
<artifactId>imageinfo</artifactId>
......
......@@ -454,14 +454,10 @@ public class DigilibRequest extends ParameterMap {
// pct:x,y,w,h -- region in % of original image
String[] parms = region.substring(4).split(",");
try {
float x = Float.parseFloat(parms[0]);
setValue("wx", x / 100f);
float y = Float.parseFloat(parms[1]);
setValue("wy", y / 100f);
float w = Float.parseFloat(parms[2]);
setValue("ww", w / 100f);
float h = Float.parseFloat(parms[3]);
setValue("wh", h / 100f);
setValue("wx", Float.parseFloat(parms[0]) / 100f);
setValue("wy", Float.parseFloat(parms[1]) / 100f);
setValue("ww", Float.parseFloat(parms[2]) / 100f);
setValue("wh", Float.parseFloat(parms[3]) / 100f);
} catch (Exception e) {
errorMessage = "Error parsing range parameter in IIIF path!";
logger.error(errorMessage, e);
......@@ -470,16 +466,16 @@ public class DigilibRequest extends ParameterMap {
} else {
// x,y,w,h -- region in pixel of original image :-(
String[] parms = region.split(",");
if (parms.length != 4) {
errorMessage = "Error parsing range parameter in IIIF path!";
logger.error(errorMessage);
return false;
} else {
try {
options.setOption("pxarea");
setValueFromString("wx", parms[0]);
setValueFromString("wy", parms[1]);
setValueFromString("ww", parms[2]);
setValueFromString("wh", parms[3]);
} catch (Exception e) {
errorMessage = "Error parsing range parameter in IIIF path!";
logger.error(errorMessage, e);
return false;
}
}
} else {
......@@ -511,26 +507,12 @@ public class DigilibRequest extends ParameterMap {
// w,h -- pixel size
try {
String[] parms = size.split(",", 2);
if (parms[0].length() > 0) {
// width param
if (parms[0].startsWith("!")) {
// width (in digilib-like bounding box)
setValueFromString("dw", parms[0].substring(1));
} else if (parms[1].length() == 0) {
// width only
setValueFromString("dw", parms[0]);
} else {
// w,h -- according to spec, we should distort the
// image to match ;-(
errorMessage = "Non-uniform-scale size parameter in IIIF path not supported!";
logger.error(errorMessage);
return false;
}
}
if (parms[1].length() > 0) {
// height param
// width param
if (!parms[0].isEmpty())
setValueFromString("dw", parms[0]);
// height param
if (!parms[1].isEmpty())
setValueFromString("dh", parms[1]);
}
} catch (Exception e) {
errorMessage = "Error parsing size parameter in IIIF path!";
logger.error(errorMessage, e);
......
......@@ -408,7 +408,7 @@ public class ImageJobDescription extends ParameterMap {
* @throws ImageOpException
*/
public double getScaleXY() throws IOException, ImageOpException {
// logger.debug("get_scaleXY()");
logger.debug("get_scaleXY()");
if (scaleXY != null) {
return scaleXY.doubleValue();
}
......@@ -439,6 +439,8 @@ public class ImageJobDescription extends ParameterMap {
areaHeight = (double) userImgArea.getHeight();
double scaleX = getDw() / areaWidth * ws;
double scaleY = getDh() / areaHeight * ws;
logger.debug("i'm here! scaleX: " + scaleX + " scaleY " + scaleY + " ws " + ws + " areaW " + areaWidth + " areaHeight " + areaHeight + "dw " + getDw() + " dh " + getDh());
scaleXY = (scaleX > scaleY) ? scaleY : scaleX;
} else if (isAbsoluteScale()) {
/*
......@@ -508,22 +510,8 @@ public class ImageJobDescription extends ParameterMap {
*/
public int getDw() throws IOException {
logger.debug("get_paramDW()");
if (paramDW == null) {
paramDW = getAsInt("dw");
paramDH = getAsInt("dh");
float imgAspect = getInput().getAspect();
if (paramDW == 0) {
// calculate dw
paramDW = Math.round(paramDH * imgAspect);
setValue("dw", paramDW);
} else if (paramDH == 0) {
// calculate dh
paramDH = Math.round(paramDW / imgAspect);
setValue("dh", paramDH);
}
}
if (paramDW == null)
computeDWH();
return paramDW;
}
......@@ -536,24 +524,32 @@ public class ImageJobDescription extends ParameterMap {
*/
public int getDh() throws IOException {
logger.debug("get_paramDH()");
if (paramDH == null) {
paramDW = getAsInt("dw");
paramDH = getAsInt("dh");
float imgAspect = getInput().getAspect();
if (paramDW == 0) {
// calculate dw
paramDW = Math.round(paramDH * imgAspect);
setValue("dw", paramDW);
} else if (paramDH == 0) {
// calculate dh
paramDH = Math.round(paramDW / imgAspect);
setValue("dh", paramDH);
}
}
if (paramDH == null)
computeDWH();
return paramDH;
}
/**
* Computes the missing parameter of destination size (if any)
* using the other one and the aspect ratio.
*
* @throws IOException
*/
private void computeDWH() throws IOException {
paramDW = getAsInt("dw");
paramDH = getAsInt("dh");
float aspect = getWAspect() * getInput().getAspect();
if (paramDW == 0) {
// calculate dw
paramDW = Math.round(paramDH * aspect);
setValue("dw", paramDW);
} else if (paramDH == 0) {
// calculate dh
paramDH = Math.round(paramDW / aspect);
setValue("dh", paramDH);
}
}
/**
* Returns the width of the image area.
......@@ -594,6 +590,16 @@ public class ImageJobDescription extends ParameterMap {
}
return paramWH;
}
/**
* Returns the ratio aspect of the image area.
*
* @return
* @throws IOException
*/
public Float getWAspect() throws IOException {
return getWw()/getWh();
}
/**
* Returns the x-offset of the image area.
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Digilib servlet config file -->
<!-- rename this file to digilib-config.xml -->
<digilib-config>
<!-- Image to be sent to indicate an error or general failure. -->
<parameter name="error-image" value="img/digilib-error.png" />
<!-- Image to be sent to indicate an authorization failure. -->
<parameter name="denied-image" value="img/digilib-denied.png" />
<!-- Image to be sent to indicate that the request was correct, but the specified image could not be found. -->
<parameter name="notfound-image" value="img/digilib-notfound.png" />
<!-- List of directories where images are searched.
Directories with low-resolution images are LAST!!! in list.
Use OS-specific path separators (":" for Unix, ";" for Windows) -->
<parameter name="basedir-list" value="/home/lerouju8/web/images" />
<!-- Java class to use for image operations -->
<!--<parameter name="docuimage-class" value="digilib.image.JAIDocuImage" />-->
<parameter name="docuimage-class" value="digilib.image.ImageLoaderDocuImage" />
<!-- mimimum amount of scaling done with antialiasing -->
<parameter name="subsample-minimum" value="2"/>
<!-- default interpolation quality (0=worst) -->
<parameter name="default-quality" value="2"/>
<!-- is sending whole image files with mo=file allowed? -->
<parameter name="sendfile-allowed" value="true" />
<!-- the a maximum size of any sent image. (0 means no limit) -->
<parameter name="max-image-size" value="0" />
<!-- number of working threads -->
<parameter name="worker-threads" value="2" />
<!-- number of waiting requests in queue -->
<parameter name="max-waiting-threads" value="20" />
<!-- timeout for asynchronous servlet worker (ms) -->
<parameter name="worker-timeout" value="60000" />
<!-- Java class to use for file metadata -->
<parameter name="filemeta-class" value="digilib.meta.IndexMetaFileMeta" />
<!-- Java class to use for directory metadata -->
<parameter name="dirmeta-class" value="digilib.meta.IndexMetaDirMeta" />
<!-- Restrict access to authorized users.
User authentication and roles are provided by the servlet container
(see tomcat-users.xml).
Authorization for resources (directories) is evaluated by the servlet
(see auth-file). -->
<parameter name="use-authorization" value="false" />
<!-- Java class to use for authentication -->
<parameter name="authops-class" value="digilib.auth.PathServletAuthOps" />
<!-- URL location of XML file with authorization requirements. -->
<parameter name="auth-file" value="digilib-auth.xml" />
<!-- Part of URL to indicate authenticated access to Tomcat. -->
<parameter name="auth-url-path" value="authenticated" />
<!-- use mapping of "virtual directories" to real directories on the server -->
<parameter name="use-mapping" value="false"/>
<!-- location of XML mapping file -->
<parameter name="mapping-file" value="digilib-map.xml"/>
<!-- location of logger config file -->
<parameter name="log-config-file" value="log4j-config.xml"/>
<!-- is the image toolkit allowed to use a disk cache -->
<parameter name="img-diskcache-allowed" value="false"/>
<!-- IIIF image API path prefix -->
<parameter name="iiif-prefix" value="IIIF"/>
<!-- IIIF image API path prefix -->
<parameter name="iiif-slash-replacement" value="!"/>
</digilib-config>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment