update bio-formats version to 6.14.0.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
|
||||
<id>bin</id>
|
||||
<formats>
|
||||
@@ -32,4 +33,4 @@
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
</assembly>
|
||||
</assembly>
|
@@ -142,14 +142,14 @@ public class BioFormatsImageInfo {
|
||||
final int seriesCount = reader.getSeriesCount();
|
||||
for (int j = 0; j < seriesCount; j++) {
|
||||
reader.setSeries(j);
|
||||
final Hashtable<String, Object> seriesMagedata = reader.getSeriesMetadata();
|
||||
if (!seriesMagedata.isEmpty()) {
|
||||
final Map<String, Object> seriesMetadata = new LinkedHashMap<String, Object>();
|
||||
final String[] keys = MetadataTools.keys(seriesMagedata);
|
||||
final Hashtable<String, Object> seriesMetadata = reader.getSeriesMetadata();
|
||||
if (!seriesMetadata.isEmpty()) {
|
||||
final Map<String, Object> originalMetadata = new LinkedHashMap<String, Object>();
|
||||
final String[] keys = MetadataTools.keys(seriesMetadata);
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
seriesMetadata.put(keys[i], seriesMagedata.get(keys[i]));
|
||||
originalMetadata.put(keys[i], seriesMetadata.get(keys[i]));
|
||||
}
|
||||
metadata.put(String.format("series[%d]", j), seriesMetadata);
|
||||
metadata.put(String.format("series[%d]", j), originalMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ public class BioFormatsImageInfo {
|
||||
// json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);
|
||||
json = mapper.writeValueAsString(map);
|
||||
} catch (final Throwable e) {
|
||||
// return "null" if conversion error occured
|
||||
// return "null" if conversion error occurred
|
||||
json = "null";
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ import loci.formats.gui.BufferedImageReader;
|
||||
|
||||
public class BioFormatsImageThumbnail {
|
||||
|
||||
protected static final float JPEG_QUORITY = 0.85f;
|
||||
protected static final float JPEG_QUALITY = 0.85f;
|
||||
protected static final int BACKGROUND_COLOR = 0x000000;
|
||||
protected static final double MAXIMUM_SCALE = 2.0;
|
||||
|
||||
@@ -39,14 +39,14 @@ public class BioFormatsImageThumbnail {
|
||||
final double scaleHeight = (double) height / (double) imageHeight;
|
||||
double scale = Math.min(scaleWidth, scaleHeight);
|
||||
if (scale > MAXIMUM_SCALE) {
|
||||
// limit scalling size to maximum scale
|
||||
// limit scaling size to maximum scale
|
||||
scale = MAXIMUM_SCALE;
|
||||
}
|
||||
int resizeWidth = imageWidth;
|
||||
int resizeHeight = imageHeight;
|
||||
Image resizeImage = image;
|
||||
if (scale != 1.0) {
|
||||
// resize image if dimension is different with requrested dimension.
|
||||
// resize image if dimension is different with requested dimension.
|
||||
resizeWidth = (int) (scale * (double) imageWidth);
|
||||
resizeHeight = (int) (scale * (double) imageHeight);
|
||||
resizeImage = image.getScaledInstance(resizeWidth, resizeHeight, Image.SCALE_AREA_AVERAGING);
|
||||
@@ -86,8 +86,8 @@ public class BioFormatsImageThumbnail {
|
||||
protected static byte[] getJpegByteArray(final BufferedImage image, final float quality, final int matColor)
|
||||
throws BioFormatsImageException {
|
||||
byte[] ret = null;
|
||||
try (final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final ImageOutputStream ios = ImageIO.createImageOutputStream(baos);) {
|
||||
try (final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
final ImageOutputStream ios = ImageIO.createImageOutputStream(bos);) {
|
||||
final ImageWriter writer = ImageIO.getImageWritersByFormatName("jpeg").next();
|
||||
final ImageWriteParam param = writer.getDefaultWriteParam();
|
||||
if (param.canWriteCompressed()) {
|
||||
@@ -97,7 +97,7 @@ public class BioFormatsImageThumbnail {
|
||||
writer.setOutput(ios);
|
||||
writer.write(null, new IIOImage(removeAlphaChannel(image, matColor), null, null), param);
|
||||
writer.dispose();
|
||||
ret = baos.toByteArray();
|
||||
ret = bos.toByteArray();
|
||||
} catch (final IOException e) {
|
||||
throw new BioFormatsImageException(e);
|
||||
}
|
||||
@@ -107,8 +107,8 @@ public class BioFormatsImageThumbnail {
|
||||
|
||||
protected static byte[] getPngByteArray(final BufferedImage image) throws BioFormatsImageException {
|
||||
byte[] ret = null;
|
||||
try (final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final ImageOutputStream ios = ImageIO.createImageOutputStream(baos);) {
|
||||
try (final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
final ImageOutputStream ios = ImageIO.createImageOutputStream(bos);) {
|
||||
final ImageWriter writer = ImageIO.getImageWritersByFormatName("png").next();
|
||||
final ImageWriteParam param = writer.getDefaultWriteParam();
|
||||
if (param.canWriteCompressed()) {
|
||||
@@ -118,7 +118,7 @@ public class BioFormatsImageThumbnail {
|
||||
writer.setOutput(ios);
|
||||
writer.write(null, new IIOImage(image, null, null), param);
|
||||
writer.dispose();
|
||||
ret = baos.toByteArray();
|
||||
ret = bos.toByteArray();
|
||||
} catch (final IOException e) {
|
||||
throw new BioFormatsImageException(e);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class BioFormatsImageThumbnail {
|
||||
bytes = getPngByteArray(image);
|
||||
break;
|
||||
case "image/jpeg":
|
||||
bytes = getJpegByteArray(image, JPEG_QUORITY, BACKGROUND_COLOR);
|
||||
bytes = getJpegByteArray(image, JPEG_QUALITY, BACKGROUND_COLOR);
|
||||
break;
|
||||
default:
|
||||
throw new BioFormatsImageException("Unsupported image format: " + mimeType);
|
||||
@@ -178,12 +178,12 @@ public class BioFormatsImageThumbnail {
|
||||
// System.out.println("series count: " + seriesCount);
|
||||
// System.out.println("image count: " + reader.getImageCount());
|
||||
// System.out.println("resolution: " + reader.getResolutionCount());
|
||||
// System.out.println("thubmail series: " + series);
|
||||
// System.out.println("thumbnail series: " + series);
|
||||
ret = reader.openThumbImage(no);
|
||||
final boolean is16bit = reader.getBitsPerPixel() > 8;
|
||||
final boolean isGrayScale = ret.getSampleModel().getNumBands() == 1;
|
||||
if (is16bit || isGrayScale) {
|
||||
// perform auto scalling if 16bit or gray scale thumbnail image.
|
||||
// perform auto scaling if 16bit or gray scale thumbnail image.
|
||||
ret = AWTImageTools.autoscale(ret);
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
|
Reference in New Issue
Block a user