code: @NotNull
      public static Metadata readMetadata(@NotNull final InputStream inputStream, final long streamLength) throws ImageProcessingException, IOException
      {
          BufferedInputStream bufferedInputStream = inputStream instanceof BufferedInputStream
              ? (BufferedInputStream)inputStream
              : new BufferedInputStream(inputStream);
  
          FileType fileType = FileTypeDetector.detectFileType(bufferedInputStream);
  
          Metadata metadata = readMetadata(bufferedInputStream, streamLength, fileType);
  
          metadata.addDirectory(new FileTypeDirectory(fileType));
  
          return metadata;
      }
docs: Reads metadata from an {@link InputStream} of known length.
  
  @param inputStream a stream from which the file data may be read.  The stream must be positioned at the
  beginning of the file's data.
  @param streamLength the length of the stream, if known, otherwise -1.
  @return a populated {@link Metadata} object containing directories of tags with values and any processing errors.
  @throws ImageProcessingException if the file type is unknown, or for general processing errors.