catch undeclared exception in higher method.
This commit is contained in:
parent
dab69b174f
commit
a4bd4b0b96
3
pom.xml
3
pom.xml
@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>jp.riken.neurodata.tools.BioFormatsImageInfo</groupId>
|
<groupId>jp.riken.neurodata.tools.BioFormatsImageInfo</groupId>
|
||||||
<artifactId>bioformats-imageinfo</artifactId>
|
<artifactId>bioformats-imageinfo</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>1.1.2</version>
|
||||||
|
|
||||||
<name>bioformats-imageinfo</name>
|
<name>bioformats-imageinfo</name>
|
||||||
<url>https://neurodata.riken.jp</url>
|
<url>https://neurodata.riken.jp</url>
|
||||||
@ -130,6 +130,7 @@
|
|||||||
<layout>default</layout>
|
<layout>default</layout>
|
||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>central</id>
|
<id>central</id>
|
||||||
|
@ -259,9 +259,9 @@ public class BioFormatsImageInfo {
|
|||||||
DebugTools.enableLogging("ERROR");
|
DebugTools.enableLogging("ERROR");
|
||||||
format = readMetadata(path, metadata);
|
format = readMetadata(path, metadata);
|
||||||
BioFormatsImageThumbnail.readThumbnail(path, thumbnail);
|
BioFormatsImageThumbnail.readThumbnail(path, thumbnail);
|
||||||
} catch (BioFormatsImageException e) {
|
} catch (Throwable t) {
|
||||||
status = false;
|
status = false;
|
||||||
message = e.getMessage();
|
message = t.getMessage();
|
||||||
metadata.clear();
|
metadata.clear();
|
||||||
thumbnail.clear();
|
thumbnail.clear();
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,10 @@ public class BioFormatsImageThumbnail {
|
|||||||
final ImageOutputStream ios = ImageIO.createImageOutputStream(baos);) {
|
final ImageOutputStream ios = ImageIO.createImageOutputStream(baos);) {
|
||||||
final ImageWriter writer = ImageIO.getImageWritersByFormatName("png").next();
|
final ImageWriter writer = ImageIO.getImageWritersByFormatName("png").next();
|
||||||
final ImageWriteParam param = writer.getDefaultWriteParam();
|
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.setOutput(ios);
|
||||||
writer.write(null, new IIOImage(image, null, null), param);
|
writer.write(null, new IIOImage(image, null, null), param);
|
||||||
writer.dispose();
|
writer.dispose();
|
||||||
@ -169,13 +172,13 @@ public class BioFormatsImageThumbnail {
|
|||||||
// System.out.println("resolution: " + reader.getResolutionCount());
|
// System.out.println("resolution: " + reader.getResolutionCount());
|
||||||
// System.out.println("thubmail series: " + series);
|
// System.out.println("thubmail series: " + series);
|
||||||
ret = reader.openThumbImage(no);
|
ret = reader.openThumbImage(no);
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable t) {
|
||||||
for (Throwable t = e; t != null; t = t.getCause()) {
|
for (Throwable e = t; e != null; e = e.getCause()) {
|
||||||
if (t instanceof OutOfMemoryError) {
|
if (t instanceof OutOfMemoryError) {
|
||||||
throw new BioFormatsImageException("out of memory");
|
throw new BioFormatsImageException("out of memory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new BioFormatsImageException(e);
|
throw new BioFormatsImageException(t);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
reader.close();
|
reader.close();
|
||||||
@ -226,7 +229,7 @@ public class BioFormatsImageThumbnail {
|
|||||||
thumbnail.put("height", height);
|
thumbnail.put("height", height);
|
||||||
thumbnail.put("mimeType", mimeType);
|
thumbnail.put("mimeType", mimeType);
|
||||||
thumbnail.put("url", dataUri);
|
thumbnail.put("url", dataUri);
|
||||||
} catch (final BioFormatsImageException e) {
|
} catch (final Throwable t) {
|
||||||
// ignore
|
// ignore
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
@ -234,7 +237,7 @@ public class BioFormatsImageThumbnail {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(final String[] args) throws BioFormatsImageException {
|
public static void main(final String[] args) {
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
System.out.println("filename argument required");
|
System.out.println("filename argument required");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
@ -248,8 +251,8 @@ public class BioFormatsImageThumbnail {
|
|||||||
final String dataUri = getDataUri(image, "image/" + format);
|
final String dataUri = getDataUri(image, "image/" + format);
|
||||||
System.out.println(dataUri);
|
System.out.println(dataUri);
|
||||||
// saveFile(dataUri, "/var/tmp/thumbnail." + format);
|
// saveFile(dataUri, "/var/tmp/thumbnail." + format);
|
||||||
} catch (final BioFormatsImageException e) {
|
} catch (final Throwable t) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(t.getMessage());
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user