advanced-cropper / vue-advanced-cropper

The advanced vue cropper library that gives you opportunity to create your own croppers suited for any website design
https://advanced-cropper.github.io/vue-advanced-cropper/
Other
1.01k stars 136 forks source link

Imagedata changes somehow. #288

Open Dylan190774 opened 1 month ago

Dylan190774 commented 1 month ago

When I do multiple tests, without changing the cropper, and use getImageDataon 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 commented 1 month ago

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.