diff --git a/generic-archiver/pom.xml b/generic-archiver/pom.xml index 41f1f7b..4d4f4a2 100644 --- a/generic-archiver/pom.xml +++ b/generic-archiver/pom.xml @@ -4,7 +4,7 @@ gov.nist.isg pyramidio-parent - 1.1.5 + 1.1.6 ${project.groupId}:${project.artifactId} Generic library to write archives folders. diff --git a/hdfs-archiver/pom.xml b/hdfs-archiver/pom.xml index d1d7521..b72766e 100644 --- a/hdfs-archiver/pom.xml +++ b/hdfs-archiver/pom.xml @@ -4,7 +4,7 @@ gov.nist.isg pyramidio-parent - 1.1.5 + 1.1.6 ${project.groupId}:${project.artifactId} Library to read and write archives on HDFS. diff --git a/pom.xml b/pom.xml index bdb08f0..6a7284d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 gov.nist.isg pyramidio-parent - 1.1.5 + 1.1.6 pom ${project.groupId}:${project.artifactId} Parent project of pyramidio, a Java tool to read and write image pyramids. Bio-Formats enhanced version. diff --git a/pyramidio-cli/pom.xml b/pyramidio-cli/pom.xml index 7f1bc75..0f85b17 100644 --- a/pyramidio-cli/pom.xml +++ b/pyramidio-cli/pom.xml @@ -4,7 +4,7 @@ gov.nist.isg pyramidio-parent - 1.1.5 + 1.1.6 ${project.groupId}:${project.artifactId} Command line interface to build image pyramids. diff --git a/pyramidio-cli/src/main/java/gov/nist/isg/pyramidio/cli/FilesArchiverFactory.java b/pyramidio-cli/src/main/java/gov/nist/isg/pyramidio/cli/FilesArchiverFactory.java index e439af1..72a8bd9 100644 --- a/pyramidio-cli/src/main/java/gov/nist/isg/pyramidio/cli/FilesArchiverFactory.java +++ b/pyramidio-cli/src/main/java/gov/nist/isg/pyramidio/cli/FilesArchiverFactory.java @@ -42,7 +42,7 @@ public class FilesArchiverFactory { public static FilesArchiver createFromURI(String uri) throws IOException { try { - URI outputURI = new URI(uri); + URI outputURI = new URI(uri.replace(" ", "%20")); String scheme = outputURI.getScheme(); logger.info("Got scheme " + scheme + " for URI " + uri); diff --git a/pyramidio-cli/src/main/java/gov/nist/isg/pyramidio/cli/Main.java b/pyramidio-cli/src/main/java/gov/nist/isg/pyramidio/cli/Main.java index 2545116..44456e0 100644 --- a/pyramidio-cli/src/main/java/gov/nist/isg/pyramidio/cli/Main.java +++ b/pyramidio-cli/src/main/java/gov/nist/isg/pyramidio/cli/Main.java @@ -68,6 +68,10 @@ public static void main(String[] args) { "Tile format such as jpg, png " + "(default to the same format than the input)"); options.addOption(tileFormatOption); + + Option forceRgbOption = new Option("rgb", "forceRGB", false, + "The output will be forced to RGB888 discarding the input image properties."); + options.addOption(forceRgbOption); Option parallelismOption = new Option("p", "parallelism", true, "Number of threads to use (default to number of cpu cores)."); @@ -139,13 +143,13 @@ public static void main(String[] args) { try { long start = System.currentTimeMillis(); - logger.info(inputFile + " - is about to start to build a pyramid."); + logger.info(inputFile + " - is about to start to build a pyramid. Output folder: " + outputFolder); try (FilesArchiver archiver = FilesArchiverFactory .createFromURI(outputFolder)) { spb.buildPyramid( //@darwinjob new DirectImageReader(inputFile), - new BioFormatsImageReader(inputFile), + new BioFormatsImageReader(inputFile, commandLine.hasOption(forceRgbOption.getOpt())), inputFileBaseName, archiver, parallelism, @@ -224,6 +228,6 @@ private static float getCalculatedPercentage(File inputFile) { } private static void printHelp(Options options) { - new HelpFormatter().printHelp("pyramidio", options); + new HelpFormatter().printHelp("java -jar pyramidio-cli-[version].jar -i my-image.jpg -o (my-output-folder || scheme:///path/file[.tar, .seq])", options); } } diff --git a/pyramidio/pom.xml b/pyramidio/pom.xml index 8df751f..172bf6b 100644 --- a/pyramidio/pom.xml +++ b/pyramidio/pom.xml @@ -6,7 +6,7 @@ gov.nist.isg pyramidio-parent - 1.1.5 + 1.1.6 ${project.groupId}:${project.artifactId} Library to read and write image pyramids. diff --git a/pyramidio/src/main/java/no/uio/nesys/pyramidio/BioFormatsImageReader.java b/pyramidio/src/main/java/no/uio/nesys/pyramidio/BioFormatsImageReader.java index 9284453..7bd296e 100644 --- a/pyramidio/src/main/java/no/uio/nesys/pyramidio/BioFormatsImageReader.java +++ b/pyramidio/src/main/java/no/uio/nesys/pyramidio/BioFormatsImageReader.java @@ -1,5 +1,6 @@ package no.uio.nesys.pyramidio; +import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.io.File; @@ -22,13 +23,32 @@ public class BioFormatsImageReader implements PartialImageReader { private BufferedImageReader bufferedImageReader; private ImageReader imageReader; + private boolean forceRGB; private static final Logger logger = Logger.getLogger( BioFormatsImageReader.class.getName()); - + /** + * Processing non RGB888 image seems to be an issue. See https://github.com/darwinjob/pyramidio-bioformats/issues/13 + * If you see any output artifacts try forceRGB=true + * @param file + * @throws FormatException + * @throws IOException + */ public BioFormatsImageReader(File file) throws FormatException, IOException { + this (file, false); + } + + /** + * + * @param file + * @param forceRGB + * @throws FormatException + * @throws IOException + */ + public BioFormatsImageReader(File file, boolean forceRGB) throws FormatException, IOException { imageReader = new ImageReader(); imageReader.setId(file.getPath()); + this.forceRGB = forceRGB; bufferedImageReader = new BufferedImageReader(imageReader); } @@ -46,12 +66,25 @@ public BufferedImage read() throws IOException { public BufferedImage read(Rectangle rectangle) throws IOException { try { logger.fine("Reading rectangle: " + rectangle); - return bufferedImageReader.openImage(0, rectangle.x, rectangle.y, rectangle.width, rectangle.height); + BufferedImage bi = bufferedImageReader.openImage(0, rectangle.x, rectangle.y, rectangle.width, rectangle.height); + + if (forceRGB) { + return convertToRGB(bi); + } + return bi; } catch (FormatException e) { throw new IOException(e); } } + private BufferedImage convertToRGB(BufferedImage src) { + BufferedImage img= new BufferedImage(src.getWidth(), src.getHeight(), BufferedImage.TYPE_INT_RGB); + Graphics2D g2d= img.createGraphics(); + g2d.drawImage(src, 0, 0, null); + g2d.dispose(); + return img; + } + @Override public int getWidth() { return imageReader.getSizeX(); diff --git a/s3-archiver/pom.xml b/s3-archiver/pom.xml index 454c091..baf2086 100644 --- a/s3-archiver/pom.xml +++ b/s3-archiver/pom.xml @@ -4,7 +4,7 @@ gov.nist.isg pyramidio-parent - 1.1.5 + 1.1.6 ${project.groupId}:${project.artifactId} Library to read and write archives on Amazon S3. diff --git a/tar-archiver/pom.xml b/tar-archiver/pom.xml index a946366..14c9519 100644 --- a/tar-archiver/pom.xml +++ b/tar-archiver/pom.xml @@ -4,7 +4,7 @@ gov.nist.isg pyramidio-parent - 1.1.5 + 1.1.6 ${project.groupId}:${project.artifactId} Library to read and write archives in tar files.