Pica: cannot use getImageData on canvas, make sure fingerprinting protection isn't enabled

Viewed 161

I am getting this error while using npm pica library. I want to resize image using this library. Have tried two ways I. by passing image url directly to pica.resize(imageurl, canvas) and II. by passing image buffer to pica.resize(imageBuffer,canvas). But it shows error Pica: cannot use getImageData on canvas, make sure fingerprinting protection isn't enabled. when I run code.

// 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));

0 Answers
Related