diff --git a/pom.xml b/pom.xml index bcdc05f..e5a8571 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 jp.riken.neurodata.tools.BioFormatsImageInfo bioformats-imageinfo - 1.1.1 + 1.1.2 bioformats-imageinfo https://neurodata.riken.jp @@ -130,6 +130,7 @@ default + central diff --git a/src/main/java/jp/riken/neurodata/tools/BioFormatsImageInfo.java b/src/main/java/jp/riken/neurodata/tools/BioFormatsImageInfo.java index d922c4f..fc5b612 100644 --- a/src/main/java/jp/riken/neurodata/tools/BioFormatsImageInfo.java +++ b/src/main/java/jp/riken/neurodata/tools/BioFormatsImageInfo.java @@ -259,9 +259,9 @@ public class BioFormatsImageInfo { DebugTools.enableLogging("ERROR"); format = readMetadata(path, metadata); BioFormatsImageThumbnail.readThumbnail(path, thumbnail); - } catch (BioFormatsImageException e) { + } catch (Throwable t) { status = false; - message = e.getMessage(); + message = t.getMessage(); metadata.clear(); thumbnail.clear(); } diff --git a/src/main/java/jp/riken/neurodata/tools/BioFormatsImageThumbnail.java b/src/main/java/jp/riken/neurodata/tools/BioFormatsImageThumbnail.java index 19a6504..0b7b5be 100644 --- a/src/main/java/jp/riken/neurodata/tools/BioFormatsImageThumbnail.java +++ b/src/main/java/jp/riken/neurodata/tools/BioFormatsImageThumbnail.java @@ -108,7 +108,10 @@ public class BioFormatsImageThumbnail { final ImageOutputStream ios = ImageIO.createImageOutputStream(baos);) { final ImageWriter writer = ImageIO.getImageWritersByFormatName("png").next(); final ImageWriteParam param = writer.getDefaultWriteParam(); - param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); + if (param.canWriteCompressed()) { + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); + param.setCompressionQuality(0.0f); + } writer.setOutput(ios); writer.write(null, new IIOImage(image, null, null), param); writer.dispose(); @@ -169,13 +172,13 @@ public class BioFormatsImageThumbnail { // System.out.println("resolution: " + reader.getResolutionCount()); // System.out.println("thubmail series: " + series); ret = reader.openThumbImage(no); - } catch (final Throwable e) { - for (Throwable t = e; t != null; t = t.getCause()) { + } catch (final Throwable t) { + for (Throwable e = t; e != null; e = e.getCause()) { if (t instanceof OutOfMemoryError) { throw new BioFormatsImageException("out of memory"); } } - throw new BioFormatsImageException(e); + throw new BioFormatsImageException(t); } finally { try { reader.close(); @@ -226,7 +229,7 @@ public class BioFormatsImageThumbnail { thumbnail.put("height", height); thumbnail.put("mimeType", mimeType); thumbnail.put("url", dataUri); - } catch (final BioFormatsImageException e) { + } catch (final Throwable t) { // ignore ret = false; } @@ -234,7 +237,7 @@ public class BioFormatsImageThumbnail { return ret; } - public static void main(final String[] args) throws BioFormatsImageException { + public static void main(final String[] args) { if (args.length != 1) { System.out.println("filename argument required"); System.exit(1); @@ -248,8 +251,8 @@ public class BioFormatsImageThumbnail { final String dataUri = getDataUri(image, "image/" + format); System.out.println(dataUri); // saveFile(dataUri, "/var/tmp/thumbnail." + format); - } catch (final BioFormatsImageException e) { - System.out.println(e.getMessage()); + } catch (final Throwable t) { + System.out.println(t.getMessage()); System.exit(1); } }