changeset 982:9e6355f7df75

merge
author hertzhaft
date Thu, 26 Jan 2012 22:07:15 +0100
parents 367f64acda4e (current diff) 5db496a7e48c (diff)
children 66db81af85e1
files
diffstat 5 files changed, 51 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/common-bioformats/pom.xml	Thu Jan 26 22:03:40 2012 +0100
+++ b/common-bioformats/pom.xml	Thu Jan 26 22:07:15 2012 +0100
@@ -26,7 +26,7 @@
   	<dependency>
   		<groupId>loci</groupId>
   		<artifactId>bio-formats</artifactId>
-  		<version>4.3.3-SNAPSHOT</version>
+  		<version>5.0-SNAPSHOT</version>
   	</dependency>
   </dependencies>
 </project>
\ No newline at end of file
--- a/common-bioformats/src/main/java/digilib/image/BioFormatsDocuImage.java	Thu Jan 26 22:03:40 2012 +0100
+++ b/common-bioformats/src/main/java/digilib/image/BioFormatsDocuImage.java	Thu Jan 26 22:07:15 2012 +0100
@@ -12,6 +12,11 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
+import ome.xml.model.primitives.PositiveInteger;
+
+import loci.common.services.DependencyException;
+import loci.common.services.ServiceException;
+import loci.common.services.ServiceFactory;
 import loci.formats.FormatException;
 import loci.formats.IFormatWriter;
 import loci.formats.ImageReader;
@@ -19,7 +24,11 @@
 import loci.formats.gui.BufferedImageReader;
 import loci.formats.gui.BufferedImageWriter;
 import loci.formats.meta.DummyMetadata;
+import loci.formats.meta.IMetadata;
 import loci.formats.meta.MetadataRetrieve;
+import loci.formats.meta.MetadataStore;
+import loci.formats.ome.OMEXMLMetadata;
+import loci.formats.services.OMEXMLService;
 
 import digilib.io.FileOpException;
 import digilib.io.ImageInput;
@@ -35,6 +44,7 @@
     private Object imageSize;
     private RenderingHints renderHint;
     private ImageReader reader;
+    private OMEXMLMetadata meta;
 
     /*
      * (non-Javadoc)
@@ -73,6 +83,14 @@
         this.input = ii;
         reader = new ImageReader();
         try {
+            // construct the object that stores OME-XML metadata
+            ServiceFactory factory = new ServiceFactory();
+            OMEXMLService service = factory.getInstance(OMEXMLService.class);
+            meta = service.createOMEXMLMetadata();
+
+            // set up the reader and associate it with the input file
+            reader = new ImageReader();
+            reader.setMetadataStore(meta);
             reader.setId(ii.getFile().getAbsolutePath());
             BufferedImageReader biReader = BufferedImageReader.makeBufferedImageReader(reader);
             img = biReader.openImage(0);
@@ -81,6 +99,12 @@
             throw new FileOpException("Unable to load image format: " + e);
         } catch (IOException e) {
             throw new FileOpException("Unable to load image file: " + e);
+        } catch (ServiceException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (DependencyException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
         }
     }
 
@@ -148,10 +172,16 @@
          */
         BufferedImageWriter writer = BufferedImageWriter.makeBufferedImageWriter(iw);
         try {
-            logger.debug("setting metadata");
-            iw.setMetadataRetrieve((MetadataRetrieve) reader.getMetadataStore());
+            logger.debug("setting metadata "+meta);
+            iw.setMetadataRetrieve(meta);
             logger.debug("writing to file  " + outFile);
             writer.setId(outFile.getAbsolutePath());
+            logger.debug("fixing metadata "+meta);
+            iw.setInterleaved(reader.isInterleaved());
+            iw.setWriteSequentially(true);
+            meta.setPixelsSizeX(new PositiveInteger(img.getWidth()), 0);
+            meta.setPixelsSizeY(new PositiveInteger(img.getHeight()), 0);
+            meta.setPixelsSizeC(new PositiveInteger(img.getColorModel().getNumComponents()), 0);
             logger.debug("saving image " + img);
             writer.saveImage(0, img);
             logger.debug("closing file");
--- a/pom.xml	Thu Jan 26 22:03:40 2012 +0100
+++ b/pom.xml	Thu Jan 26 22:07:15 2012 +0100
@@ -49,71 +49,57 @@
         <groupId>org.jdom</groupId>
         <artifactId>jdom</artifactId>
         <version>1.1</version>
-        <type>jar</type>
-        <scope>compile</scope>
     </dependency>
     <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
         <version>1.2.14</version>
-        <type>jar</type>
-        <scope>compile</scope>
     </dependency>
+    <!-- digilib module versions -->
     <dependency>
     	<groupId>digilib</groupId>
     	<artifactId>digilib-common</artifactId>
     	<version>2.1-SNAPSHOT</version>
-    	<type>jar</type>
-    	<scope>compile</scope>
     </dependency>
     <dependency>
     	<groupId>digilib</groupId>
     	<artifactId>digilib-common-jai</artifactId>
     	<version>2.1-SNAPSHOT</version>
-    	<type>jar</type>
-    	<scope>compile</scope>
     </dependency>
     <dependency>
     	<groupId>digilib</groupId>
     	<artifactId>digilib-common-imagej</artifactId>
     	<version>2.1-SNAPSHOT</version>
-    	<type>jar</type>
-    	<scope>compile</scope>
+    </dependency>
+    <dependency>
+    	<groupId>digilib</groupId>
+    	<artifactId>digilib-common-bioformats</artifactId>
+    	<version>2.1-SNAPSHOT</version>
     </dependency>
     <dependency>
     	<groupId>digilib</groupId>
     	<artifactId>digilib-pdf</artifactId>
     	<version>2.1-SNAPSHOT</version>
-    	<type>jar</type>
-    	<scope>compile</scope>
     </dependency>
     <dependency>
     	<groupId>digilib</groupId>
     	<artifactId>digilib-text</artifactId>
     	<version>2.1-SNAPSHOT</version>
-    	<type>jar</type>
-    	<scope>compile</scope>
     </dependency>
     <dependency>
     	<groupId>digilib</groupId>
     	<artifactId>digilib-servlet2</artifactId>
     	<version>2.1-SNAPSHOT</version>
-    	<type>jar</type>
-    	<scope>compile</scope>
     </dependency>
     <dependency>
     	<groupId>digilib</groupId>
     	<artifactId>digilib-servlet3</artifactId>
     	<version>2.1-SNAPSHOT</version>
-    	<type>jar</type>
-    	<scope>compile</scope>
     </dependency>
     <dependency>
     	<groupId>digilib</groupId>
     	<artifactId>digilib-webapp</artifactId>
     	<version>2.1-SNAPSHOT</version>
-    	<type>war</type>
-    	<scope>compile</scope>
     </dependency>
   	</dependencies>
   </dependencyManagement>
@@ -151,6 +137,7 @@
     <module>common</module>
     <module>common-jai</module>
     <module>common-imagej</module>
+    <module>common-bioformats</module>
     <module>servlet2</module>
     <module>servlet3</module>
     <module>pdf</module>
--- a/webapp/pom.xml	Thu Jan 26 22:03:40 2012 +0100
+++ b/webapp/pom.xml	Thu Jan 26 22:07:15 2012 +0100
@@ -142,5 +142,16 @@
         </dependency>
       </dependencies>
     </profile>
+    <profile>
+      <id>codec-bioformats</id>
+      <dependencies>
+        <dependency>
+          <groupId>digilib</groupId>
+          <artifactId>digilib-common-bioformats</artifactId>
+          <type>jar</type>
+          <scope>compile</scope>
+        </dependency>
+      </dependencies>
+    </profile>
   </profiles>
 </project>
--- a/webapp/src/main/webapp/WEB-INF/digilib-config.xml	Thu Jan 26 22:03:40 2012 +0100
+++ b/webapp/src/main/webapp/WEB-INF/digilib-config.xml	Thu Jan 26 22:07:15 2012 +0100
@@ -18,7 +18,6 @@
 
   <!-- Java class to use for image operations -->
   <parameter name="docuimage-class" value="digilib.image.ImageLoaderDocuImage" />
-  <!-- <parameter name="docuimage-class" value="digilib.image.ImageJ1DocuImage" /> -->
 
   <!-- mimimum amount of scaling done with antialiasing -->
   <parameter name="subsample-minimum" value="2"/>