assets/js/testing-batch.js in appscms-tools-theme-2.3.0 vs assets/js/testing-batch.js in appscms-tools-theme-2.3.1

- old
+ new

@@ -1,6 +1,5 @@ -const opacity = document.querySelector("#opacity") const batchConversion = async (file, indexValue) => { return new Promise((resolve, reject) => { if (file) { const reader = new FileReader() reader.readAsDataURL(file) @@ -11,12 +10,21 @@ canvas.setAttribute('id', 'canvas-img') let ctx = canvas.getContext('2d') image.onload = () => { canvas.width = image.width canvas.height = image.height - ctx.globalAlpha = opacity.value - ctx.drawImage(image, 0, 0, canvas.width, canvas.height) - resolve([indexValue, canvas.toDataURL('image/png'), "image"]) + // counter.innerHTML = e.target.value + "%" + let filters = document.querySelector('#applyFilter') + if (filters.getAttribute('data-filter') === "opacity") { + ctx.globalAlpha = filters.value + ctx.drawImage(image, 0, 0, canvas.width, canvas.height) + resolve([indexValue, canvas.toDataURL('image/png'), "image"]) + } else { + ctx.filter = filters.getAttribute('data-filter') + '(' + filters.value + filters.getAttribute('data-scale') + ') ' + ctx.drawImage(image, 0, 0, canvas.width, canvas.height) + resolve([indexValue, canvas.toDataURL('image/png'), "image"]) + } + } image.src = e.target.result } } }