docs: public static List<File> createTiffFiles(File imageFile, int index, boolean preserve) throws IOException {
          List<File> tiffFiles = new ArrayList<File>();
  
          String imageFormat = getImageFileFormat(imageFile);
  
          Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName(imageFormat);
          if (!readers.hasNext()) {
              throw new RuntimeException(JAI_IMAGE_READER_MESSAGE);
          }
          ImageReader reader = readers.next();
  
          // Get tiff writer and set output to file
          Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName(TIFF_FORMAT);
          if (!writers.hasNext()) {
              throw new RuntimeException(JAI_IMAGE_WRITER_MESSAGE);
          }
          ImageWriter writer = writers.next();
  
          try (ImageInputStream iis = ImageIO.createImageInputStream(imageFile)) {
              reader.setInput(iis);
              // Read the stream metadata
              // IIOMetadata streamMetadata = reader.getStreamMetadata();
  
              // Set up the writeParam
              TIFFImageWriteParam tiffWriteParam = new TIFFImageWriteParam(Locale.US);
              if (!preserve) {
                  // not preserve original sizes; decompress
                  tiffWriteParam.setCompressionMode(ImageWriteParam.MODE_DISABLED);
              }
              // Read the stream metadata
              IIOMetadata streamMetadata = writer.getDefaultStreamMetadata(tiffWriteParam);
  
              int imageTotal = reader.getNumImages(true);
  
              for (int i = 0; i < imageTotal; i++) {
                  // all if index == -1; otherwise, only index-th
                  if (index == -1 || i == index) {
                      IIOImage oimage = reader.readAll(i, reader.getDefaultReadParam());
                      File tiffFile = File.createTempFile(OUTPUT_FILE_NAME, TIFF_EXT);
                      try (ImageOutputStream ios = ImageIO.createImageOutputStream(tiffFile)) {
                          writer.setOutput(ios);
                          writer.write(streamMetadata, oimage, tiffWriteParam);
                          tiffFiles.add(tiffFile);
                      }
                  }
              }
  
              return tiffFiles;
          } finally {
              if (reader != null) {
                  reader.dispose();
              }
              if (writer != null) {
                  writer.dispose();
              }
          }
      }