From 4ea1e61202815341749957c914f3ce28582f96ab Mon Sep 17 00:00:00 2001 From: thanhld Date: Sat, 30 Nov 2019 11:20:22 +0700 Subject: [PATCH] fix broken pixel when crop image --- croppie.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/croppie.js b/croppie.js index 2652d0ef..848e982d 100755 --- a/croppie.js +++ b/croppie.js @@ -1225,6 +1225,14 @@ } // console.table({ left, right, top, bottom, canvasWidth, canvasHeight, width, height, startX, startY, circle, sx, sy, dx, dy, sWidth, sHeight, dWidth, dHeight }); + + // When the pixel from source position is directly transfered to the destination position, loosing all the neighbouring pixels information. The resulting image may often look very noisy. + // Set these properties is a simple area-average downsampling, producing preferable results with relatively small processing time. + ctx.mozImageSmoothingEnabled = true; + ctx.imageSmoothingQuality = "high"; + ctx.webkitImageSmoothingEnabled = true; + ctx.msImageSmoothingEnabled = true; + ctx.imageSmoothingEnabled = true; ctx.drawImage(this.elements.preview, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight); if (circle) {