docs: public static void mergeTiff(File[] inputImages, File outputTiff) throws IOException {
          if (inputImages.length == 0) {
              // if no image
              return;
          }
  
          Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName(TIFF_FORMAT);
          if (!writers.hasNext()) {
              throw new RuntimeException(JAI_IMAGE_WRITER_MESSAGE);
          }
          ImageWriter writer = writers.next();
  
          //Set up the writeParam
          TIFFImageWriteParam tiffWriteParam = new TIFFImageWriteParam(Locale.US);
  //        tiffWriteParam.setCompressionMode(ImageWriteParam.MODE_DISABLED); // commented out to preserve original sizes
  
          //Get the stream metadata
          IIOMetadata streamMetadata = writer.getDefaultStreamMetadata(tiffWriteParam);
  
          try (ImageOutputStream ios = ImageIO.createImageOutputStream(outputTiff)) {
              writer.setOutput(ios);
              boolean firstPage = true;
              int index = 1;
              for (File inputImage : inputImages) {
                  String imageFileFormat = getImageFileFormat(inputImage);
                  Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName(imageFileFormat);
                  if (!readers.hasNext()) {
                      throw new RuntimeException(JAI_IMAGE_READER_MESSAGE);
                  }
                  ImageReader reader = readers.next();
                  try (ImageInputStream iis = ImageIO.createImageInputStream(inputImage)) {
                      reader.setInput(iis);
                      int imageTotal = reader.getNumImages(true);
                      for (int i = 0; i < imageTotal; i++) {
                          IIOImage oimage = reader.readAll(i, reader.getDefaultReadParam());
                          if (firstPage) {
                              writer.write(streamMetadata, oimage, tiffWriteParam);
                              firstPage = false;
                          } else {
                              writer.writeInsert(index++, oimage, tiffWriteParam);
                          }
                      }
                  } finally {
                      if (reader != null) {
                          reader.dispose();
                      }
                  }
              }
          } finally {
              writer.dispose();
          }
      }