code: protected void checkBounds(int index) throws IOException {
          assertInput();
          if (index < getMinIndex()) {
              throw new IndexOutOfBoundsException("index < minIndex");
          }
  
          int numImages = getNumImages(false);
          if (numImages != -1 && index >= numImages) {
              throw new IndexOutOfBoundsException("index >= numImages (" + index + " >= " + numImages + ")");
          }
      }
docs: Convenience method to make sure image index is within bounds.
  
  @param index the image index
  
  @throws java.io.IOException if an error occurs during reading
  @throws IndexOutOfBoundsException if not {@code minIndex <= index < numImages}