Pica:无法在画布上使用 getImageData,请确保未启用指纹识别保护

Nik*_*tel 5 javascript node.js npm

我在使用库时遇到此错误npm pica。我想使用这个库调整图像大小。尝试了两种方法 I. 直接传递图像 urlpica.resize(imageurl, canvas)和 II. 通过将图像缓冲区传递给pica.resize(imageBuffer,canvas). 但它显示错误 Pica: 无法在画布上使用 getImageData,请确保未启用指纹识别保护。当我运行代码时。

// Convert Base64 to BufferArray
    const buf = Buffer.from(img, 'base64');

    let binary = '';
    const chunk = 8 * 1024;
    let i;
    for (i = 0; i < buf.length / chunk; i += 1) {
      binary += String.fromCharCode.apply(null, [
        ...buf.slice(i * chunk, (i + 1) * chunk),
      ]);
    }
    binary += String.fromCharCode.apply(null, [...buf.slice(i * chunk)]);

    // Dimensions for the image
    const width = 1200;
    const height = 627;

    // Instantiate the canvas object
    const can = canvas.createCanvas(width,height);
    // const context = canvas.getContext("2d");
    console.log(binary)
    
    pica.resize(binary, can)
        .then(result => console.log(result));
Run Code Online (Sandbox Code Playgroud)