changeset 935:776347921bec

fixed slowness of tiff with color profile by loading into srgb.
author robcast
date Wed, 21 Dec 2011 17:02:28 +0100
parents 065dd6895ce7
children 172079f9a398
files common/src/main/java/digilib/image/ImageLoaderDocuImage.java servlet3/src/main/java/digilib/servlet/Scaler.java
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/common/src/main/java/digilib/image/ImageLoaderDocuImage.java	Wed Dec 21 17:01:13 2011 +0100
+++ b/common/src/main/java/digilib/image/ImageLoaderDocuImage.java	Wed Dec 21 17:02:28 2011 +0100
@@ -47,6 +47,7 @@
 import javax.imageio.ImageIO;
 import javax.imageio.ImageReadParam;
 import javax.imageio.ImageReader;
+import javax.imageio.ImageTypeSpecifier;
 import javax.imageio.ImageWriteParam;
 import javax.imageio.ImageWriter;
 import javax.imageio.stream.FileImageInputStream;
@@ -311,8 +312,8 @@
 		return reader;
 	}
 
-	/* Load an image file into the Object. */
-	public void loadSubimage(ImageInput ii, Rectangle region, int prescale)
+    /* Load an image file into the Object. */
+    public void loadSubimage(ImageInput ii, Rectangle region, int prescale)
 			throws FileOpException {
 		logger.debug("loadSubimage");
         this.input = ii;
@@ -325,6 +326,16 @@
 			if (prescale > 1) {
 				readParam.setSourceSubsampling(prescale, prescale, 0, 0);
 			}
+			// try to restrict target color space to sRGB
+			for (Iterator<ImageTypeSpecifier> i = reader.getImageTypes(0); i.hasNext(); ) {
+			    ImageTypeSpecifier type = (ImageTypeSpecifier) i.next();
+			    ColorSpace cs = type.getColorModel().getColorSpace();
+			    if (cs.isCS_sRGB()) {
+	                logger.debug("loadSubimage: substituted sRGB destination type "+type);
+			        readParam.setDestinationType(type);
+			        break;
+			    }
+			}
 			// read image
 			logger.debug("loading..");
 			img = reader.read(0, readParam);
--- a/servlet3/src/main/java/digilib/servlet/Scaler.java	Wed Dec 21 17:01:13 2011 +0100
+++ b/servlet3/src/main/java/digilib/servlet/Scaler.java	Wed Dec 21 17:02:28 2011 +0100
@@ -31,7 +31,7 @@
     private static final long serialVersionUID = 5289386646192471549L;
 
     /** digilib servlet version (for all components) */
-    public static final String version = "2.0b3 async";
+    public static final String version = "2.0b4 async";
 
     /** servlet error codes */
     public static enum Error {