docs: public static void mergeTiff(List<IIOImage> imageList, File outputTiff, String compressionType) throws IOException {
          if (imageList == null || imageList.isEmpty()) {
              // 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); // comment out to preserve original sizes
          if (compressionType != null) {
              tiffWriteParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
              tiffWriteParam.setCompressionType(compressionType);
          }
  
          //Get the stream metadata
          IIOMetadata streamMetadata = writer.getDefaultStreamMetadata(tiffWriteParam);
  
          try (ImageOutputStream ios = ImageIO.createImageOutputStream(outputTiff)) {
              writer.setOutput(ios);
  
              int dpiX = 300;
              int dpiY = 300;
  
              for (IIOImage iioImage : imageList) {
                  // Get the default image metadata.
                  ImageTypeSpecifier imageType = ImageTypeSpecifier.createFromRenderedImage(iioImage.getRenderedImage());
                  ImageWriteParam param = writer.getDefaultWriteParam();
                  IIOMetadata imageMetadata = writer.getDefaultImageMetadata(imageType, param);
                  imageMetadata = setDPIViaAPI(imageMetadata, dpiX, dpiY);
                  iioImage.setMetadata(imageMetadata);
              }
  
              IIOImage firstIioImage = imageList.remove(0);
              writer.write(streamMetadata, firstIioImage, tiffWriteParam);
  
              int i = 1;
              for (IIOImage iioImage : imageList) {
                  writer.writeInsert(i++, iioImage, tiffWriteParam);
              }
          } finally {
              writer.dispose();
          }
      }