Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
toBlob(type = 'image/png', quality = 0.8) {
return canvasToBlob(this.getCanvas(), type, quality);
},
img.onload = () => {
const width = img.width
const height = img.height
const resizedWidth = options.width ? Math.ceil(options.width) : width / 2
const resizedHeight = Math.ceil(height * resizedWidth / width)
canvas.width = width
canvas.height = height
ctx.drawImage(img, 0, 0)
blobUtil.canvasToBlob(hermiteResize(canvas, width, height, resizedWidth, resizedHeight))
.then(blob => {
blobUtil.revokeObjectURL(img.src)
resolve(blob)
})
.catch(error => {
blobUtil.revokeObjectURL(img.src)
reject(error)
})
}
})