Disable DEBUG logging of BioFormats writer

Hi @s.besson @joshmoore ,

I have two questions:

  1. When I use Bio-Formats as shown in below code it produces a lot of DEBUG logging output (see below). Could this be disabled? I have the feeling it slows down the process and in particular it is hard for me to see any of my own text outputs.

  2. When saving one image plane to disc, is the code I have below the fastest option? Or can one change this to somehow increase the writing speed?

CODE

            ImageWriter writer = new ImageWriter();
            writer.setValidBitsPerPixel( imp.getBytesPerPixel() * 8 );
            writer.setMetadataRetrieve( meta );
            writer.setId( getPath( true, nC, nT ) );
            writer.setWriteSequentially( true ); // ? is this necessary
            
            if ( compression.equals( SavingSettings.COMPRESSION_LZW ) )
                writer.setCompression( TiffWriter.COMPRESSION_LZW );
            else if ( compression.equals( SavingSettings.COMPRESSION_ZLIB ) )
                writer.setCompression( TiffWriter.COMPRESSION_ZLIB );

            if (imp.getBytesPerPixel() == 2)
                writer.saveBytes( 0, ShortToByteBigEndian((short[]) imp.getStack().getProcessor(1).getPixels() ) );
            else if (imp.getBytesPerPixel() == 1)
                writer.saveBytes( 0, (byte[]) (imp.getStack().getProcessor(1).getPixels() ) );

DEBUG output (partial)

16:46:58.161 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 111/125 size: 12 offset: 13043
16:46:58.161 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 112/125 size: 12 offset: 13055
16:46:58.161 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 113/125 size: 12 offset: 13067
16:46:58.161 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 114/125 size: 12 offset: 13079
16:46:58.162 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 115/125 size: 12 offset: 13091
16:46:58.162 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 116/125 size: 12 offset: 13103
16:46:58.162 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 117/125 size: 12 offset: 13115
16:46:58.162 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 118/125 size: 12 offset: 13127
16:46:58.162 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 119/125 size: 12 offset: 13139
16:46:58.162 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 120/125 size: 12 offset: 13151
16:46:58.162 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 121/125 size: 12 offset: 13163
16:46:58.162 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 122/125 size: 12 offset: 13175
16:46:58.162 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 123/125 size: 12 offset: 13187
16:46:58.163 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 124/125 size: 12 offset: 13199
16:46:58.163 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip 125/125 size: 12 offset: 13211
16:46:58.163 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Offset before IFD write: 13223 Seeking to: 8
16:46:58.163 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip offsets: [1309, 1321, 1333, 1345, 1357, 1369, 1381, 1393, 1405, 1417, 1429, 1441, 1453, 1465, 1477, 1489, 1501, 1513, 1525, 1537, 1549, 1561, 1573, 1585, 1597, 1609, 1621, 1633, 1645, 1657, 1669, 1681, 1693, 1705, 1717, 1729, 1741, 1753, 1904, 2126, 2342, 2552, 2774, 3007, 3242, 3477, 3710, 3947, 4186, 4427, 4669, 4912, 5159, 5398, 5631, 5843, 6041, 6244, 6436, 6629, 6823, 7016, 7205, 7398, 7585, 7768, 7955, 8137, 8319, 8505, 8687, 8868, 9040, 9217, 9388, 9564, 9742, 9917, 10093, 10266, 10440, 10614, 10788, 10962, 11133, 11300, 11468, 11628, 11791, 11948, 12111, 12268, 12425, 12588, 12751, 12863, 12875, 12887, 12899, 12911, 12923, 12935, 12947, 12959, 12971, 12983, 12995, 13007, 13019, 13031, 13043, 13055, 13067, 13079, 13091, 13103, 13115, 13127, 13139, 13151, 13163, 13175, 13187, 13199, 13211]
16:46:58.163 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Writing tile/strip byte counts: [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 151, 222, 216, 210, 222, 233, 235, 235, 233, 237, 239, 241, 242, 243, 247, 239, 233, 212, 198, 203, 192, 193, 194, 193, 189, 193, 187, 183, 187, 182, 182, 186, 182, 181, 172, 177, 171, 176, 178, 175, 176, 173, 174, 174, 174, 174, 171, 167, 168, 160, 163, 157, 163, 157, 157, 163, 163, 112, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12]
16:46:58.166 [pool-2-thread-4] DEBUG loci.formats.tiff.TiffSaver - Offset after IFD write: 1309

You can set the logging level by using:
DebugTools.setRootLevel(level)

Setting it to DebugTools.setRootLevel("OFF") will disable the debugging completely.

Otherwise your code looks to be fine, the compression stage may take some time which might explain why it seems to be quite slow.

1 Like