Sha256: a3ffd1ad9b92e051baac30b934351dbd430638ac3cec4eece6faaac73e1a8bc5

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

const opacity = document.querySelector("#opacity")
const batchConversion = async (file, indexValue) => {
    return new Promise((resolve, reject) => {
        if (file) {
            const reader = new FileReader()
            reader.readAsDataURL(file)
            reader.onload = (e) => {
                if (e.target.result) {
                    let image = new Image()
                    let canvas = document.createElement('canvas')
                    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"])
                    }
                    image.src = e.target.result
                }
            }
        }
    })
}



Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
appscms-tools-theme-2.3.0 assets/js/testing-batch.js
appscms-tools-theme-2.2.9 assets/js/testing-batch.js
appscms-tools-theme-2.2.8 assets/js/testing-batch.js
appscms-tools-theme-2.2.7 assets/js/testing-batch.js
appscms-tools-theme-2.2.6 assets/js/testing-batch.js
appscms-tools-theme-2.2.5 assets/js/testing-batch.js
appscms-tools-theme-2.2.4 assets/js/testing-batch.js