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

Imagedata changes somehow. #288

Open
Dylan190774 opened this issue Oct 10, 2024 · 1 comment
Open

Imagedata changes somehow. #288

Dylan190774 opened this issue Oct 10, 2024 · 1 comment

Comments

@Dylan190774
Copy link

Dylan190774 commented Oct 10, 2024

When I do multiple tests, without changing the cropper, and use getImageData on the canvas, I get different ImageData the second time. After that it somehow stabilizes and returns the same.

I have no idea why this is happening.
Here's my Typescript (and Vue3) code:

  const result = cropperRef.value?.getResult();

  if (result && result.canvas) {
    let imagedata: Uint8ClampedArray = new Uint8ClampedArray(0);
    const ctx = result.canvas.getContext('2d');
    if (ctx) {
      const imageData = ctx.getImageData(
        0,
        0,
        result.canvas.width,
        result.canvas.height,
      );
      imagedata = imageData.data;
    }

    console.log(imagedata);
  }

Any idea why this data could be different when nothing else was changed?

@Dylan190774
Copy link
Author

It seems this has something to do with farbling, which Brave Browser does by default on each canvas. It's for security reasons. Kinda sucks though, since this causes the canvas to be (a tiny little bit) different from time to time, which is not what I want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant