@@ -421,6 +421,103 @@ public void testConvertResolutionsSingleZ() throws FormatException, IOException
421421 assertEquals (meta .getPixelsSizeT (0 ).getValue ().intValue (), 1 );
422422 }
423423
424+ /**
425+ * Generate a pyramid with the defined number of resolutions.
426+ */
427+ @ Test
428+ public void testGenerateDefinedResolutions () throws FormatException , IOException {
429+ outFile = getOutFile ("defined-pyramid.ome.tiff" );
430+ String [] args = {
431+ "defined-pyramid&sizeX=8100&sizeY=7500.fake" ,
432+ "-pyramid-resolutions" , "4" ,
433+ "-pyramid-scale" , "2" ,
434+ outFile .getAbsolutePath ()
435+ };
436+ resolutionCount = 4 ;
437+ assertConversion (args , outFile .getAbsolutePath (), 8100 );
438+
439+ IMetadata meta = getOMEXMLMetadata (outFile );
440+ assertEquals (meta .getImageCount (), 1 );
441+ }
442+
443+ /**
444+ * Generate a pyramid with downsample factor of 3.
445+ */
446+ @ Test
447+ public void testPyramidFactor3 () throws FormatException , IOException {
448+ outFile = getOutFile ("factor-3.ome.tiff" );
449+ String [] args = {
450+ "factor-3&sizeX=8100&sizeY=7500.fake" ,
451+ "-pyramid-resolutions" , "4" ,
452+ "-pyramid-scale" , "3" ,
453+ outFile .getAbsolutePath ()
454+ };
455+ resolutionCount = 4 ;
456+ assertConversion (args , outFile .getAbsolutePath (), 8100 );
457+
458+ IMetadata meta = getOMEXMLMetadata (outFile );
459+ assertEquals (meta .getImageCount (), 1 );
460+ }
461+
462+ /**
463+ * Generate a pyramid, where the defined number of resolutions is unreasonably large.
464+ */
465+ @ Test
466+ public void testGenerateTooManyResolutions () throws FormatException , IOException {
467+ outFile = getOutFile ("big-pyramid.ome.tiff" );
468+ String [] args = {
469+ "big-pyramid&sizeX=6073&sizeY=9247.fake" ,
470+ "-pyramid-resolutions" , "20" ,
471+ "-pyramid-scale" , "2" ,
472+ outFile .getAbsolutePath ()
473+ };
474+ // 20 is too many, so the count should be reset
475+ resolutionCount = 13 ;
476+ assertConversion (args , outFile .getAbsolutePath (), 6073 );
477+
478+ IMetadata meta = getOMEXMLMetadata (outFile );
479+ assertEquals (meta .getImageCount (), 1 );
480+ }
481+
482+ /**
483+ * Generate a pyramid, but calculate internally how many resolutions are needed.
484+ */
485+ @ Test
486+ public void testGenerateCalculatedResolutions () throws FormatException , IOException {
487+ outFile = getOutFile ("calculated-pyramid.ome.tiff" );
488+ String [] args = {
489+ "calculated-pyramid&sizeX=7673&sizeY=1541.fake" ,
490+ "-pyramid-scale" , "2" ,
491+ outFile .getAbsolutePath ()
492+ };
493+ resolutionCount = 10 ;
494+ assertConversion (args , outFile .getAbsolutePath (), 7673 );
495+
496+ IMetadata meta = getOMEXMLMetadata (outFile );
497+ assertEquals (meta .getImageCount (), 1 );
498+ }
499+
500+ /**
501+ * Generate a pyramid, but calculate internally how many resolutions are needed
502+ * based on specified tile size.
503+ */
504+ @ Test
505+ public void testGenerateCalculatedResolutionsByTileSize () throws FormatException , IOException {
506+ outFile = getOutFile ("tile-size-calculated-pyramid.ome.tiff" );
507+ String [] args = {
508+ "calculated-pyramid&sizeX=7673&sizeY=1541.fake" ,
509+ "-pyramid-scale" , "2" ,
510+ "-tilex" , "512" ,
511+ "-tiley" , "512" ,
512+ outFile .getAbsolutePath ()
513+ };
514+ resolutionCount = 2 ;
515+ assertConversion (args , outFile .getAbsolutePath (), 7673 );
516+
517+ IMetadata meta = getOMEXMLMetadata (outFile );
518+ assertEquals (meta .getImageCount (), 1 );
519+ }
520+
424521 private Path getTempSubdir () throws IOException {
425522 Path subdir = Files .createTempDirectory (tempDir , "ImageConverterTest" );
426523 subdir .toFile ().deleteOnExit ();
0 commit comments