@@ -123,13 +123,13 @@ public class PyramidFromDirectoryWriter implements Callable<Void> {
123
123
/** Where to write? */
124
124
Path outputFilePath ;
125
125
Path inputDirectory ;
126
- private volatile String logLevel = "WARN" ;
126
+ private volatile String logLevel ;
127
127
private volatile boolean progressBars = false ;
128
128
boolean printVersion = false ;
129
- CompressionType compression = CompressionType . LZW ;
129
+ CompressionType compression ;
130
130
CodecOptions compressionOptions ;
131
131
boolean legacy = false ;
132
- int maxWorkers = Runtime . getRuntime (). availableProcessors () ;
132
+ int maxWorkers ;
133
133
boolean rgb = false ;
134
134
135
135
private List <PyramidSeries > series = new ArrayList <PyramidSeries >();
@@ -148,7 +148,6 @@ public class PyramidFromDirectoryWriter implements Callable<Void> {
148
148
* Construct a writer for performing the pyramid conversion.
149
149
*/
150
150
public PyramidFromDirectoryWriter () {
151
- tileQueue = new LimitedQueue <Runnable >(maxWorkers );
152
151
}
153
152
154
153
/**
@@ -159,11 +158,17 @@ public PyramidFromDirectoryWriter() {
159
158
@ Parameters (
160
159
index = "1" ,
161
160
arity = "1" ,
162
- description = "Relative path to the output OME-TIFF file"
161
+ description = "Relative path to the output OME-TIFF file" ,
162
+ defaultValue = Option .NULL_VALUE
163
163
)
164
164
public void setOutputPath (String output ) {
165
165
// could be expanded to allow other output locations
166
- outputFilePath = Paths .get (output );
166
+ if (output != null ) {
167
+ outputFilePath = Paths .get (output );
168
+ }
169
+ else {
170
+ outputFilePath = null ;
171
+ }
167
172
}
168
173
169
174
/**
@@ -174,11 +179,17 @@ public void setOutputPath(String output) {
174
179
@ Parameters (
175
180
index = "0" ,
176
181
arity = "1" ,
177
- description = "Directory containing pixel data to convert"
182
+ description = "Directory containing pixel data to convert" ,
183
+ defaultValue = Option .NULL_VALUE
178
184
)
179
185
public void setInputPath (String input ) {
180
186
// could be expanded to allow other input locations
181
- inputDirectory = Paths .get (input );
187
+ if (input != null ) {
188
+ inputDirectory = Paths .get (input );
189
+ }
190
+ else {
191
+ inputDirectory = null ;
192
+ }
182
193
}
183
194
184
195
/**
@@ -208,7 +219,8 @@ public void setLogLevel(String level) {
208
219
@ Option (
209
220
names = {"-p" , "--progress" },
210
221
description = "Print progress bars during conversion" ,
211
- help = true
222
+ help = true ,
223
+ defaultValue = "false"
212
224
)
213
225
public void setProgressBars (boolean useProgressBars ) {
214
226
progressBars = useProgressBars ;
@@ -223,7 +235,8 @@ public void setProgressBars(boolean useProgressBars) {
223
235
@ Option (
224
236
names = "--version" ,
225
237
description = "Print version information and exit" ,
226
- help = true
238
+ help = true ,
239
+ defaultValue = "false"
227
240
)
228
241
public void setPrintVersionOnly (boolean versionOnly ) {
229
242
printVersion = versionOnly ;
@@ -271,7 +284,8 @@ public void setCompression(CompressionType compressionType) {
271
284
@ Option (
272
285
names = "--quality" ,
273
286
converter = CompressionQualityConverter .class ,
274
- description = "Compression quality"
287
+ description = "Compression quality" ,
288
+ defaultValue = Option .NULL_VALUE
275
289
)
276
290
public void setCompressionOptions (CodecOptions options ) {
277
291
compressionOptions = options ;
@@ -286,7 +300,8 @@ public void setCompressionOptions(CodecOptions options) {
286
300
*/
287
301
@ Option (
288
302
names = "--legacy" ,
289
- description = "Write a Bio-Formats 5.9.x pyramid instead of OME-TIFF"
303
+ description = "Write a Bio-Formats 5.9.x pyramid instead of OME-TIFF" ,
304
+ defaultValue = "false"
290
305
)
291
306
public void setLegacyTIFF (boolean legacyTIFF ) {
292
307
legacy = legacyTIFF ;
@@ -300,26 +315,36 @@ public void setLegacyTIFF(boolean legacyTIFF) {
300
315
@ Option (
301
316
names = "--split" ,
302
317
description =
303
- "Split output into one OME-TIFF file per OME Image/Zarr group"
318
+ "Split output into one OME-TIFF file per OME Image/Zarr group" ,
319
+ defaultValue = "false"
304
320
)
305
321
public void setSplitTIFFs (boolean split ) {
306
322
splitBySeries = split ;
307
323
}
308
324
309
325
/**
310
326
* Set the maximum number of workers to use for converting tiles.
311
- * Defaults to the number of detected CPUs.
327
+ * Defaults to 4 or the number of detected CPUs, whichever is smaller .
312
328
*
313
329
* @param workers maximum worker count
314
330
*/
315
331
@ Option (
316
332
names = "--max_workers" ,
317
- description = "Maximum number of workers (default: ${DEFAULT-VALUE})"
333
+ description = "Maximum number of workers (default: ${DEFAULT-VALUE})" ,
334
+ defaultValue = "4"
318
335
)
319
336
public void setMaxWorkers (int workers ) {
320
- if (workers > 0 ) {
337
+ int availableProcessors = Runtime .getRuntime ().availableProcessors ();
338
+ int prevWorkers = getMaxWorkers ();
339
+ if (workers > availableProcessors ) {
340
+ maxWorkers = availableProcessors ;
341
+ }
342
+ else if (workers > 0 && workers != maxWorkers ) {
321
343
maxWorkers = workers ;
322
344
}
345
+ if (prevWorkers != maxWorkers ) {
346
+ tileQueue = new LimitedQueue <Runnable >(maxWorkers );
347
+ }
323
348
}
324
349
325
350
/**
@@ -332,7 +357,8 @@ public void setMaxWorkers(int workers) {
332
357
@ Option (
333
358
names = "--rgb" ,
334
359
description = "Attempt to write channels as RGB; " +
335
- "channel count must be a multiple of 3"
360
+ "channel count must be a multiple of 3" ,
361
+ defaultValue = "false"
336
362
)
337
363
public void setRGB (boolean isRGB ) {
338
364
rgb = isRGB ;
@@ -342,13 +368,19 @@ public void setRGB(boolean isRGB) {
342
368
* @return path to output data
343
369
*/
344
370
public String getOutputPath () {
371
+ if (outputFilePath == null ) {
372
+ return null ;
373
+ }
345
374
return outputFilePath .toString ();
346
375
}
347
376
348
377
/**
349
378
* @return path to input data
350
379
*/
351
380
public String getInputPath () {
381
+ if (inputDirectory == null ) {
382
+ return null ;
383
+ }
352
384
return inputDirectory .toString ();
353
385
}
354
386
0 commit comments