var obj = getValue(); var image = new Image(); image.src = obj.src; var canvas = $('<canvas width="' + obj.width + '" height="' + obj.height + '"></canvas>')[0], ctx = canvas.getContext('2d'); ctx.drawImage( image, obj.x, obj.y, obj.width, obj.height, 0, 0, obj.width, obj.height); var data = canvas.toDataURL("image/png");
_this.distory(); console.log(data); $crop.data('src', data); $("#crop_imgID").attr("src",data);