fromCanvas
API reference for the "fromCanvas" method.
const { imageHelpers } = window.canva;
const canva = window.canva.init();
canva.onReady(async () => {
// Create an HTMLCanvasElement
const canvas = document.createElement("canvas");
// Convert an HTMLCanvasElement into a CanvaImageBlob
const image = await imageHelpers.fromCanvas("image/jpeg", canvas);
// Do something with the result
console.log(image);
});
Name | Type | Required | Description |
---|---|---|---|
imageType | string | Yes | The MIME type of the CanvaImageBlob . The possible values are "image/jpeg" , "image/png" , and "image/svg+xml" . |
canvas | HTMLCanvasElement | Yes | The HTMLCanvasElement to convert into a CanvaImageBlob . |
quality | number | No | The quality of the converted image, represented as a number from 0-100. A value of 100 is the highest quality. |
Promise<CanvaImageBlob>
Last modified 1yr ago