update bio-formats version to 6.14.0.
This commit is contained in:
parent
705e7f7e7d
commit
4c581052ab
8
.vscode/extensions.json
vendored
Normal file
8
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"vscjava.vscode-java-pack",
|
||||
"esbenp.prettier-vscode",
|
||||
"mosapride.zenkaku",
|
||||
"streetsidesoftware.code-spell-checker"
|
||||
]
|
||||
}
|
17
.vscode/settings.json
vendored
Normal file
17
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports": true
|
||||
},
|
||||
"[jsonc]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
// Extensions - Code Spell Checker
|
||||
"cSpell.ignoreWords": ["endianness", "noflat", "nopix", "omexml"],
|
||||
"cSpell.words": ["bioformats", "imageinfo", "neurodata", "riken"],
|
||||
// Extentions - Prettier
|
||||
"prettier.printWidth": 120,
|
||||
"prettier.singleQuote": true,
|
||||
"prettier.tabWidth": 4,
|
||||
"java.configuration.updateBuildConfiguration": "interactive"
|
||||
}
|
10
README.md
10
README.md
@ -1,27 +1,33 @@
|
||||
# BioFormatsImageInfo
|
||||
|
||||
Metadata extraction tool based on Bio-Formats
|
||||
|
||||
### make package
|
||||
|
||||
```shell
|
||||
mvn package
|
||||
```
|
||||
|
||||
### run
|
||||
|
||||
```shell
|
||||
./target/dist/bin/bioformats-imageinfo "[path to image file]"
|
||||
```
|
||||
|
||||
### run by jar
|
||||
|
||||
```shell
|
||||
java -jar ./target/dist/lib/bioformats-imageinfo-1.1.3.jar "[path to image file]"
|
||||
java -jar ./target/dist/lib/bioformats-imageinfo-1.1.4.jar "[path to image file]"
|
||||
```
|
||||
|
||||
### run by fat jar
|
||||
|
||||
```shell
|
||||
java -jar ./target/bioformats-imageinfo-1.1.3-jar-with-dependencies.jar "[path to image file]"
|
||||
java -jar ./target/bioformats-imageinfo-1.1.4-jar-with-dependencies.jar "[path to image file]"
|
||||
```
|
||||
|
||||
### library usage
|
||||
|
||||
```java
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
14
pom.xml
14
pom.xml
@ -1,15 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>jp.riken.neurodata.tools.BioFormatsImageInfo</groupId>
|
||||
<artifactId>bioformats-imageinfo</artifactId>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4</version>
|
||||
|
||||
<name>bioformats-imageinfo</name>
|
||||
<url>https://neurodata.riken.jp</url>
|
||||
|
||||
<properties>
|
||||
<bio-formats.version>6.12.0</bio-formats.version>
|
||||
<bio-formats.version>6.14.0</bio-formats.version>
|
||||
<bioformats-imageinfo.mainClass>jp.riken.neurodata.tools.BioFormatsImageInfo</bioformats-imageinfo.mainClass>
|
||||
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
@ -57,7 +59,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
@ -111,7 +113,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<version>3.6.0</version>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
@ -138,7 +140,7 @@
|
||||
<plugin>
|
||||
<groupId>org.owasp</groupId>
|
||||
<artifactId>dependency-check-maven</artifactId>
|
||||
<version>8.2.1</version>
|
||||
<version>8.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
@ -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>
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user