Skip to content

Commit

Permalink
Merge pull request #4200 from tstoeter/develop
Browse files Browse the repository at this point in the history
Allow processing multiple files sequentially in a single run, with file names read from stdin.
  • Loading branch information
sbesson authored Sep 2, 2024
2 parents ce9031f + a569f5a commit aaaf99d
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
import java.io.File;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Scanner;
import java.util.Arrays;
import java.util.List;

import loci.common.ByteArrayHandle;
import loci.common.DataTools;
Expand Down Expand Up @@ -311,6 +314,8 @@ public void printUsage() {
"",
" -version: print the library version and exit",
" file: the image file to read",
" if - is passed, process multiple files",
" with file names read line-wise from stdin",
" -nopix: read metadata only, not pixels",
" -nocore: do not output core metadata",
" -nometa: do not parse format-specific metadata table",
Expand Down Expand Up @@ -1126,7 +1131,25 @@ private void printDimension(String dim, int size, int effectiveSize,

public static void main(String[] args) throws Exception {
DebugTools.enableLogging("INFO");
if (!new ImageInfo().testRead(args)) System.exit(1);

List<String> argsList = Arrays.asList(args);
int idx = argsList.indexOf("-");

if (idx >= 0) {
Scanner scanner = new Scanner(System.in);
String[] newArgs = argsList.toArray(new String[0]);

while (scanner.hasNext()) {
newArgs[idx] = scanner.nextLine();
System.out.println("====% " + newArgs[idx]);
if (!new ImageInfo().testRead(newArgs)) System.exit(1);
}
scanner.close();
}
else {
if (!new ImageInfo().testRead(args)) System.exit(1);
}
}

}

0 comments on commit aaaf99d

Please sign in to comment.