From 98008badfe397a09da5195d78cce3d0e8e28e5ff Mon Sep 17 00:00:00 2001 From: Kyle <41976328+ImKyle4815@users.noreply.github.com> Date: Fri, 2 Nov 2018 19:56:57 -0700 Subject: [PATCH] Fixed watermarks and added automatic image cropping --- data/scripts/autocrop.js | 5 +++-- data/scripts/loadImage.js | 1 + index.html | 19 +++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/data/scripts/autocrop.js b/data/scripts/autocrop.js index 4efbbc03..ebb9b9ef 100644 --- a/data/scripts/autocrop.js +++ b/data/scripts/autocrop.js @@ -8,6 +8,7 @@ function autocrop(url, destination) { //Create image, size canvas, draw image var imgTempSetSymbol = new Image() + imgTempSetSymbol.crossOrigin = "anonymous" imgTempSetSymbol.src = url imgTempSetSymbol.onload = function() { if (imgTempSetSymbol.width > 0 && imgTempSetSymbol.height > 0) { @@ -41,8 +42,8 @@ height = pix.y[n] - pix.y[0] var cropped = cropContext.getImageData(pix.x[0], pix.y[0], width + 1, height + 1) //Resizes the canvas and draws cropped image - cropCanvas.width = width - cropCanvas.height = height + cropCanvas.width = width + 1 + cropCanvas.height = height + 1 cropContext.putImageData(cropped, 0, 0) //Saves the newly cropped image to the given image destination.src = cropCanvas.toDataURL() diff --git a/data/scripts/loadImage.js b/data/scripts/loadImage.js index 2548d224..b80b6d58 100644 --- a/data/scripts/loadImage.js +++ b/data/scripts/loadImage.js @@ -5,6 +5,7 @@ function loadImage(event, destination, arg) { reader.onload = function() { var dataURL = reader.result destination.src = dataURL + destination.cropped = false } reader.readAsDataURL(input.files[0]) } diff --git a/index.html b/index.html index 226a9f9e..25866054 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ - +