How to use the blob-util.canvasToBlob function in blob-util

To help you get started, we’ve selected a few blob-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github image-js / image-js / src / image / core / export.js View on Github external
toBlob(type = 'image/png', quality = 0.8) {
    return canvasToBlob(this.getCanvas(), type, quality);
  },
github morkro / happy-plants / src / utils / blob.js View on Github external
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)
        })
    }
  })