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
931 stars 130 forks source link

Canvas undefined when using .getResult() #166

Closed edshen17 closed 2 years ago

edshen17 commented 2 years ago

Hello, I was playing around with the Twitter showcase and wanted to get the canvas from getResult(). However, it returns undefined.

Please check this fork. It's basically the same code, but I print the result in onChange().

I know that the documentation says that this example uses undocumented/unreleased features, but is there any way I can get the canvas, or the cropped image after zoom/movement? My end goal is to construct a blob with canvas.toBlob().

Thanks, Edwin.

Norserium commented 2 years ago

Hello, @edshen17!

The props canvas is false, that's the reason why the canvas from getResult is undefined.

You can enable canvas, but in this case I recommend to get the result not on change, but on some action. For example, clicking the button continue.

See the second method of the getting result.

edshen17 commented 2 years ago

Thank you for the quick reply! It works now once I set canvas to false.

Ah yes, I was just trying to show that it was undefined since it was easy to do in the onChange method. Thanks again!

Norserium commented 2 years ago

@edshen17, you are welcome!