I am trying to get cropped image result from cropperjs but I dont know how to get it. I tried to search online but couldn't find a solution.
My code is as given below.
$(function ()
{
$image=null;
var img = document.createElement("IMG");
img.src = "";
img.setAttribute('id', "showImage");
document.getElementById("img-container").appendChild(img);
var url = canvas.toDataURL();
canvasImage.src = url;
console.log(canvasImage);
document.getElementById("showImage").src=canvasImage.src;
$image = $('#showImage');
$image.cropper({
movable: true,
zoomable: false,
rotatable: false,
scalable: false
});
$('#replace').on('click', function () {
var croppedimage = new Image();
var cropBoxData = $image.cropper('getCropBoxData');
croppedimage=$image.data('cropper');
// croppedimage= this.cropper.
console.log($image);
});
});
$('#replace').on('click', function () {
var croppedimage = $image.getCroppedCanvas().toDataURL("image/png");
console.log(croppedimage);
});
you can get base64
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With