private void checkIndex(int imageIndex) {
   int noOfPages = decoder.getNumberOfPages();
   if (imageIndex < 0 || imageIndex > noOfPages) throw new IndexOutOfBoundsException("Bad index!");
 }
  public int getNumImages(boolean allowSearch) throws IOException {
    readFile();

    return decoder.getNumberOfPages();
  }