Compare commits
2 Commits
f81a1c2fbd
...
6bd2bbc572
Author | SHA1 | Date | |
---|---|---|---|
6bd2bbc572 | |||
6d29af7f72 |
@ -26,14 +26,17 @@ java -jar ./target/bioformats-imageinfo-1.1.0-jar-with-dependencies.jar "[path t
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import jp.riken.neurodata.tools.BioFormatsImageInfo;
|
import jp.riken.neurodata.tools.BioFormatsImageInfo;
|
||||||
import jp.riken.neurodata.tools.BioFormatsException;
|
import jp.riken.neurodata.tools.BioFormatsImageException;
|
||||||
|
import jp.riken.neurodata.tools.BioFormatsImageThumbnail;
|
||||||
|
|
||||||
String path = "[path to image file]";
|
String path = "[path to image file]";
|
||||||
String format = "";
|
String format = "";
|
||||||
Map<String, Object> metadata = new LinkedHashMap<String, Object>();
|
Map<String, Object> metadata = new LinkedHashMap<String, Object>();
|
||||||
|
Map<String, Object> thumbnail = new LinkedHashMap<String, Object>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
format = BioFormatsImageInfo.readMetadata(path, metadata);
|
format = BioFormatsImageInfo.readMetadata(path, metadata);
|
||||||
|
BioFormatsImageThumbnail.readThumbnail(path, thumbnail);
|
||||||
} catch (BioFormatsImageException e) {
|
} catch (BioFormatsImageException e) {
|
||||||
// error occurred
|
// error occurred
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -31,7 +31,7 @@ public class BioFormatsImageThumbnail {
|
|||||||
protected static final int BACKGROUND_COLOR = 0x000000;
|
protected static final int BACKGROUND_COLOR = 0x000000;
|
||||||
protected static final double MAXIMUM_SCALE = 2.0;
|
protected static final double MAXIMUM_SCALE = 2.0;
|
||||||
|
|
||||||
protected static BufferedImage resize(final BufferedImage image, final int width, final int height) {
|
public static BufferedImage resize(final BufferedImage image, final int width, final int height) {
|
||||||
final boolean hasAlpha = image.getColorModel().hasAlpha();
|
final boolean hasAlpha = image.getColorModel().hasAlpha();
|
||||||
final int imageWidth = image.getWidth();
|
final int imageWidth = image.getWidth();
|
||||||
final int imageHeight = image.getHeight();
|
final int imageHeight = image.getHeight();
|
||||||
@ -46,7 +46,7 @@ public class BioFormatsImageThumbnail {
|
|||||||
int resizeHeight = imageHeight;
|
int resizeHeight = imageHeight;
|
||||||
Image resizeImage = image;
|
Image resizeImage = image;
|
||||||
if (scale != 1.0) {
|
if (scale != 1.0) {
|
||||||
// resize image if dimension is larger than maximum dimention.
|
// resize image if dimension is different with requrested dimension.
|
||||||
resizeWidth = (int) (scale * (double) imageWidth);
|
resizeWidth = (int) (scale * (double) imageWidth);
|
||||||
resizeHeight = (int) (scale * (double) imageHeight);
|
resizeHeight = (int) (scale * (double) imageHeight);
|
||||||
resizeImage = image.getScaledInstance(resizeWidth, resizeHeight, Image.SCALE_AREA_AVERAGING);
|
resizeImage = image.getScaledInstance(resizeWidth, resizeHeight, Image.SCALE_AREA_AVERAGING);
|
||||||
@ -242,8 +242,8 @@ public class BioFormatsImageThumbnail {
|
|||||||
final String format = image.getColorModel().hasAlpha() ? "png" : "jpeg";
|
final String format = image.getColorModel().hasAlpha() ? "png" : "jpeg";
|
||||||
// image = resize(image, 160, 160);
|
// image = resize(image, 160, 160);
|
||||||
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 BioFormatsImageException e) {
|
||||||
System.out.println(e.getMessage());
|
System.out.println(e.getMessage());
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user