code: public static int getNumberOfPages(RandomAccessFileOrArray s) {
          try {
              return TIFFDirectory.getNumDirectories(s);
          }
          catch (Exception e) {
              throw new ExceptionConverter(e);
          }
      }
docs: Gets the number of pages the TIFF document has.
  @param s the file source
  @return the number of pages