# HG changeset patch
# User robcast
# Date 1292599443 -3600
# Node ID baaa5bab5e16162091eab93d5f9ebb8625437de2
# Parent a5168978555f8a8589e1c91a449226368eb9e7de
trying to reduce use of ImageOps
diff -r a5168978555f -r baaa5bab5e16 servlet/src/digilib/image/DocuImage.java
--- a/servlet/src/digilib/image/DocuImage.java Fri Dec 17 11:53:31 2010 +0100
+++ b/servlet/src/digilib/image/DocuImage.java Fri Dec 17 16:24:03 2010 +0100
@@ -214,7 +214,7 @@
/**
* Check image size and type and store in ImageFile f
*/
- public boolean identify(ImageFile imgf) throws IOException;
+ public ImageFile identify(ImageFile imgf) throws IOException;
/**
* Returns a list of supported image formats
diff -r a5168978555f -r baaa5bab5e16 servlet/src/digilib/image/DocuImageImpl.java
--- a/servlet/src/digilib/image/DocuImageImpl.java Fri Dec 17 11:53:31 2010 +0100
+++ b/servlet/src/digilib/image/DocuImageImpl.java Fri Dec 17 16:24:03 2010 +0100
@@ -39,7 +39,7 @@
/** Simple abstract implementation of the DocuImage
interface.
*
* This implementation provides basic functionality for the utility methods like
- * SetUtils
, and getKnownFileTypes
. Image methods like
+ * getKnownFileTypes
. Image methods like
* loadImage
, writeImage
, getWidth
,
* getHeight
, crop
and scale
must be
* implemented by derived classes.
@@ -75,11 +75,7 @@
}
/** Check image size and type and store in ImageFile f */
- public static boolean identifyImg(ImageFile imgf) throws IOException {
- }
-
- /** Check image size and type and store in ImageFile f */
- public boolean identify(ImageFile imgf) throws IOException {
+ public ImageFile identify(ImageFile imgf) throws IOException {
// fileset to store the information
File f = imgf.getFile();
if (f == null) {
@@ -100,9 +96,9 @@
//logger.debug(" format:"+iif.getFormatName());
raf.close();
logger.debug("image size: " + imgf.getSize());
- return true;
+ return imgf;
}
- return false;
+ return null;
}
/** Crop and scale the current image.
@@ -122,7 +118,7 @@
public void cropAndScale(
int x_off, int y_off, int width, int height, double scale, int qual)
throws ImageOpException {
-
+ // default implementation: first crop, then scale
setQuality(qual);
crop(x_off, y_off, width, height);
scale(scale, scale);
@@ -171,7 +167,6 @@
public void crop(int xoff, int yoff, int width, int height)
throws ImageOpException {
// TODO Auto-generated method stub
-
}
public Image getAwtImage() {
diff -r a5168978555f -r baaa5bab5e16 servlet/src/digilib/image/ImageJobDescription.java
--- a/servlet/src/digilib/image/ImageJobDescription.java Fri Dec 17 11:53:31 2010 +0100
+++ b/servlet/src/digilib/image/ImageJobDescription.java Fri Dec 17 16:24:03 2010 +0100
@@ -2,7 +2,9 @@
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
+import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Method;
import org.apache.log4j.Logger;
@@ -133,7 +135,7 @@
if (mimeType == null) {
fileToLoad = getFileToLoad();
if(! fileToLoad.isChecked()){
- ImageOps.checkFile(fileToLoad);
+ dlConfig.docuImageIdentify(fileToLoad);
}
mimeType = fileToLoad.getMimetype();
}
@@ -250,12 +252,11 @@
if (getAbsoluteScale()) {
ImageFile hiresFile = fileset.getBiggest();
if (!hiresFile.isChecked()) {
- ImageOps.checkFile(hiresFile);
+ dlConfig.docuImageIdentify(hiresFile);
}
hiresSize = hiresFile.getSize();
}
return hiresSize;
-
}
/** Returns image scaling factor.
diff -r a5168978555f -r baaa5bab5e16 servlet/src/digilib/image/ImageOps.java
--- a/servlet/src/digilib/image/ImageOps.java Fri Dec 17 11:53:31 2010 +0100
+++ b/servlet/src/digilib/image/ImageOps.java Fri Dec 17 16:24:03 2010 +0100
@@ -37,7 +37,7 @@
private static DocuImage docuImg;
- public static boolean checkFile(ImageFile imgf) throws IOException {
+ public static ImageFile checkFile(ImageFile imgf) throws IOException {
return docuImg.identify(imgf);
}
diff -r a5168978555f -r baaa5bab5e16 servlet/src/digilib/servlet/DigilibConfiguration.java
--- a/servlet/src/digilib/servlet/DigilibConfiguration.java Fri Dec 17 11:53:31 2010 +0100
+++ b/servlet/src/digilib/servlet/DigilibConfiguration.java Fri Dec 17 16:24:03 2010 +0100
@@ -22,6 +22,7 @@
package digilib.servlet;
import java.io.File;
+import java.io.IOException;
import java.util.Map;
import java.util.Map.Entry;
@@ -34,6 +35,7 @@
import digilib.image.DocuImage;
import digilib.image.DocuImageImpl;
import digilib.io.FileOps;
+import digilib.io.ImageFile;
import digilib.io.XMLListLoader;
import digilib.util.Parameter;
import digilib.util.ParameterMap;
@@ -55,6 +57,9 @@
/** DocuImage class instance */
private Class docuImageClass = null;
+ /** DocuImage instance */
+ private DocuImage docuImage = null;
+
/** Log4J logger */
private Logger logger = Logger.getLogger("digilib.config");
@@ -270,12 +275,20 @@
return di;
}
+ public ImageFile docuImageIdentify(ImageFile imgf) throws IOException {
+ if (docuImage == null) {
+ docuImage = (DocuImageImpl) getDocuImageInstance();
+ }
+ return docuImage.identify(imgf);
+ }
+
/**
* @return Returns the docuImageClass.
*/
public Class getDocuImageClass() {
return docuImageClass;
}
+
/**
* @param docuImageClass The docuImageClass to set.
*/