@Override
  public boolean canDecodeInput(@NotNull Object source) throws IOException {
    if (!(source instanceof ImageInputStream stream)) return false;

    long length = stream.length();
    // The length may be -1 for files of unknown size.
    // Accept them for now and if needed, throw an IOException later.
    if (length > MAX_FILE_SIZE) {
      return false;
    }

    stream.mark();
    try {
      byte[] header = new byte[12];
      int bytesRead = stream.read(header, 0, 12);
      return bytesRead == 12 &&
             arrayEquals(header, 0, RIFF_HEADER.length, RIFF_HEADER) &&
             arrayEquals(header, 8, WEBP_HEADER.length, WEBP_HEADER) &&
             WebpNativeLibHelper.loadNativeLibraryIfNeeded();
    }
    finally {
      try {
        stream.reset();
      }
      catch (IOException e) {
        Logger.getInstance(WebpImageReaderSpi.class).error(e);
      }
    }
  }
@Override
  public boolean canDecodeInput(@NotNull Object source)