title: How to Get Total Page Count From Tiff
body: <p>I have started to create a new method in our project to return total pages. We are using <code>TIFFTweaker</code> which can be referenced from the following URL - <a href="https://github.com/dragon66/icafe/blob/master/src/com/icafe4j/image/tiff/TIFFTweaker.java" rel="nofollow noreferrer">https://github.com/dragon66/icafe/blob/master/src/com/icafe4j/image/tiff/TIFFTweaker.java</a></p>
  
  <p>In this class I found a method <code>TIFFTweaker.getPageCount()</code> which looks like it wants a <code>RandomAccessInputStream</code> object for their <code>getPageCount()</code>. </p>
  
  <p>I've been playing around with trying to get from my file object over to what they're looking for. </p>
  
  <p>What would be the best way to approach this and return the total pages from the tiff?</p>
  
  <p>I have looked over some java docs, stackOverflow and some random blogs but can't seem to figure out how to get from a file object to a <code>randomaccessinputstream</code>.</p>
  
  <pre><code>@Override
  public Integer totalPages(File file) {
  
  Integer numberOfPages = 0;
  try{
        //TIFFTweaker.getPageCount(); - How to pass the file and get the count? Problem is type is a random access input stream and I have a file type
  
         FileInputStream fileInputStream = new FileInputStream(file);
         String absolutePath = file.getAbsolutePath();
  
         // return TIFFTweaker.getPageCount();
  
    }catch(IOException e){
          log.error("Error with Tiff File" + e);
     }
  
  return null;
  
  }
  </code></pre>
  
  <p>I am expecting a numeric value returned which represents the total number of pages in the <code>TIFF</code> file I'm passing.</p>