Skip to content

Commit

Permalink
antialiasing issue fixes #91
Browse files Browse the repository at this point in the history
  • Loading branch information
thedustinsmith committed Mar 7, 2016
1 parent 0df7516 commit 8ac551b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions croppie.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,16 +807,15 @@
canvas.width = outWidth;
canvas.height = outHeight;

ctx.drawImage(img, left, top, width, height, 0, 0, outWidth, outHeight);
if (circle) {
ctx.save();
ctx.fillStyle = '#fff';
ctx.globalCompositeOperation = 'destination-in';
ctx.beginPath();
ctx.arc(outWidth / 2, outHeight / 2, outWidth / 2, 0, Math.PI * 2, true);
ctx.closePath();
ctx.clip();
ctx.fill();
}

ctx.drawImage(img, left, top, width, height, 0, 0, outWidth, outHeight);

return canvas.toDataURL(data.format, data.quality);
}

Expand Down
2 changes: 1 addition & 1 deletion demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var Demo = (function() {
$('.js-main-image').on('click', function (ev) {
mc.croppie('result', {
type: 'canvas',
format: 'jpeg'
format: 'png'
}).then(function (resp) {
popupResult({
src: resp
Expand Down

0 comments on commit 8ac551b

Please sign in to comment.