diff servlet/src/digilib/io/ImageFile.java @ 585:95417c4615b8 stream

more cleanup for ImageFileSet
author robcast
date Wed, 05 Jan 2011 14:41:28 +0100
parents 7357ad8f9f42
children aee436f0549d
line wrap: on
line diff
--- a/servlet/src/digilib/io/ImageFile.java	Wed Jan 05 12:12:19 2011 +0100
+++ b/servlet/src/digilib/io/ImageFile.java	Wed Jan 05 14:41:28 2011 +0100
@@ -22,8 +22,10 @@
 package digilib.io;
 
 import java.io.File;
+import java.io.IOException;
 
 import digilib.image.ImageSize;
+import digilib.servlet.DigilibConfiguration;
 
 /**
  * @author casties
@@ -64,7 +66,49 @@
 		this.parent = parent;
 	}
 	
-	/** Returns the file name (without path).
+	
+	/** Checks the image and sets size and type.
+	 * 
+	 */
+	public void check() {
+	    if (pixelSize == null) {
+	        try {
+	            // use the configured toolkit to identify the image
+                DigilibConfiguration.identifyDocuImage(this);
+            } catch (IOException e) {
+                // nothing much to do...
+            }
+	    }
+	}
+	
+	/* (non-Javadoc)
+     * @see digilib.io.ImageInput#getSize()
+     */
+    @Override
+    public ImageSize getSize() {
+        check();
+        return pixelSize;
+    }
+
+    /* (non-Javadoc)
+     * @see digilib.io.ImageInput#getMimetype()
+     */
+    @Override
+    public String getMimetype() {
+        check();
+        return mimetype;
+    }
+
+    /* (non-Javadoc)
+     * @see digilib.io.ImageInput#getAspect()
+     */
+    @Override
+    public float getAspect() {
+        check();
+        return (pixelSize != null) ? pixelSize.getAspect() : 0f;
+    }
+
+    /** Returns the file name (without path).
 	 * 
 	 * @return
 	 */
@@ -72,7 +116,6 @@
 		return name;
 	}
 
-
 	/**
 	 * @return File
 	 */