var jcrop_api, boundx, boundy;
function updatePreview(c) { // croping image preview
if (parseInt(c.w) > 0) {
var rx = 220 / c.w, ry = 220 / c.h;
}
}
function showCoords(c) { // show all coords
$('#x').val(c.x);
$('#y').val(c.y);
$('#x2').val(c.x2);
$('#y2').val(c.y2);
$('#w').val(c.w);
$('#h').val(c.h);
}
$('.thumbnail-img').Jcrop({
onChange: updatePreview,
onSelect: showCoords,
bgFade: true,
bgOpacity: .2,
setSelect: [ 0, 0, 220, 220 ],
aspectRatio: 1
},function(){
jcrop_api = this;
});
$("#crop").on("click", function(){
var canvas = document.getElementById("canvas_mask");
var context = canvas.getContext("2d");
$img = $(img),
imgW = img.width,
imgH = img.height;
var ratioY = imgH / $img.height(),
ratioX = imgW / $img.width();
var getX = $('#x').val() * ratioX,
getY = $('#y').val() * ratioY,
getWidth = $('#w').val() * ratioX,
getHeight = $('#h').val() * ratioY;
context.drawImage(img,getX,getY,getWidth,getHeight,0,0,320,320);
});
I am not able to catch why this error coming