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
1k stars 136 forks source link

willReadFrequently on getResult() canvas ? #287

Open Dylan190774 opened 2 months ago

Dylan190774 commented 2 months ago

In devtools console I get the following warning:

Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently

This happens when I use const result = this.$refs.cropper.getResult(); a few times after another and then do getImageData on the context of result.canvas

Any idea how to set willReadFrequently on the canvas of getResult?

Dylan190774 commented 2 months ago

Found the solution, I just had to use :

const ctx = canvas.getContext('2d', { willReadFrequently: true }); when getting the context of the canvas.