Reputation: 1568
I am using cropper js to crop images. more info at: https://github.com/fengyuanchen/cropperjs
so this is my javascript code to get cropped picture as canvas
var result = document.getElementById('result');
result.innerHTML = '';
result.appendChild(cropper.getCroppedCanvas());
Result div:
<div id="result"></div>
after cropped it returns to me canvas inside result div
<div id="result"> <canvas width="137" height="137"></canvas></div>
My question is how to return as <img src=""></img>
instead of <canvas>
tag ?
Upvotes: 0
Views: 199
Reputation: 3113
var image = new Image();
image.id = "pic"
image.src = cropper.getCroppedCanvas().toDataURL();
document.getElementById('image_for_crop').appendChild(image);
Upvotes: 3