jquery-cropbox
jquery-cropbox copied to clipboard
Retina support
getDataURL: function () {
var canvas = document.createElement('canvas'), ctx = canvas.getContext('2d');
var pixelRatio = window.devicePixelRatio || 1;
canvas.width = this.options.width * pixelRatio;
canvas.height = this.options.height * pixelRatio;
ctx.scale(pixelRatio, pixelRatio);
ctx.drawImage(this.$image.get(0), this.result.cropX, this.result.cropY,
this.result.cropW, this.result.cropH, 0, 0,
this.options.width, this.options.height);
return canvas.toDataURL();
},
see: https://tristandunn.com/2014/01/24/rendering-svg-on-canvas/