ColorThief.getColor() TypeError: url.indexOf is not a function

ColorThief.getColor() TypeError: url.indexOf is not a function

我正在尝试在 node.js 环境中使用 ColorThief。调用 ColorThief.getColor() 时出现以下错误:

TypeError: url.indexOf is not a function

错误是由模块中的这行代码引起的。

if(url.indexOf('data:image/gif;') 

这是我的代码:

const ColorThief = require('colorthief');
const img = document.querySelector('#image');
ColorThief.getColor(img)
    .then(color => { console.log(color) })
    .catch(err => { console.log(err) })

感谢任何解决此问题的帮助。

来自 https://lokeshdhakar.com/projects/color-thief 文档

getColor(image [, quality])

image - When called in the browser, this argument expects an HTML image element, not a URL. When run in Node, this argument expects a path to the image.