Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unusable with picajs #11

Open
yann86 opened this issue May 4, 2022 · 0 comments
Open

Unusable with picajs #11

yann86 opened this issue May 4, 2022 · 0 comments

Comments

@yann86
Copy link

yann86 commented May 4, 2022

Hi,

Thanks for your code it's very usefull, however I can't use it with picajs.

In my app I use pica js for resizing pictures, when I use your polyfill I have an error:

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

Internally pica use this code to check if browser block fingerprinting with getImageData

function can_use_canvas(createCanvas) {
  var usable = false;

  try {
    var canvas = createCanvas(2, 1);
    var ctx = canvas.getContext('2d');
    var d = ctx.createImageData(2, 1);
    d.data[0] = 12;
    d.data[1] = 23;
    d.data[2] = 34;
    d.data[3] = 255;
    d.data[4] = 45;
    d.data[5] = 56;
    d.data[6] = 67;
    d.data[7] = 255;
    ctx.putImageData(d, 0, 0);
    d = null;
    d = ctx.getImageData(0, 0, 2, 1);

    if (d.data[0] === 12 && d.data[1] === 23 && d.data[2] === 34 && d.data[3] === 255 && d.data[4] === 45 && d.data[5] === 56 && d.data[6] === 67 && d.data[7] === 255) {
      usable = true;
    }
  } catch (err) {}

  return usable;
};

function createCanvas(width, height) {
  var tmpCanvas = document.createElement('canvas');
  tmpCanvas.width = width;
  tmpCanvas.height = height;
  return tmpCanvas;
}
can_use_canvas(createCanvas)


Can you help me with this issue I really would like to use your polyfill with picajs

@yann86 yann86 changed the title Unusable with picas Unusable with picajs May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants