From bc4be44174dc273c6f8d4dc66ab7351ef1753c2d Mon Sep 17 00:00:00 2001 From: serizawa Date: Thu, 31 Oct 2024 19:16:06 +0900 Subject: [PATCH] implement option parameter --- .../neurodata/tools/BioFormatsImageInfo.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/main/java/jp/riken/neurodata/tools/BioFormatsImageInfo.java b/src/main/java/jp/riken/neurodata/tools/BioFormatsImageInfo.java index 0c4615b..aaee5cf 100644 --- a/src/main/java/jp/riken/neurodata/tools/BioFormatsImageInfo.java +++ b/src/main/java/jp/riken/neurodata/tools/BioFormatsImageInfo.java @@ -248,17 +248,34 @@ public class BioFormatsImageInfo { boolean status = true; String message = ""; String format = ""; + boolean metadataON = true; + boolean thumbnailON = true; + String path = ""; final Map metadata = new LinkedHashMap(); final Map thumbnail = new LinkedHashMap(); - if (args.length != 1) { - status = false; - message = "filename argument required"; + if (args.length == 1) { + path = args[0]; + } else if (args.length == 2) { + if (args[0].startsWith("-")) { + metadataON = args[0].toUpperCase().contains("M"); + thumbnailON = args[0].toUpperCase().contains("T"); + } + path = args[1]; } else { - final String path = args[0]; + status = false; + message = "invalid parameters"; + message += "\nUsage ./target/dist/bin/bioformats-imageinfo \"[OPTION]\" \"[path to image file]\""; + message += "\n-M output metadata\n-T output thumbnail"; + } + if (status) { try { DebugTools.enableLogging("OFF"); - format = readMetadata(path, metadata); - BioFormatsImageThumbnail.readThumbnail(path, thumbnail); + if (metadataON) { + format = readMetadata(path, metadata); + } + if (thumbnailON) { + BioFormatsImageThumbnail.readThumbnail(path, thumbnail); + } } catch (Throwable t) { status = false; message = t.getMessage();