fromCanvas
API reference for the "fromCanvas" method.
Converts an HTMLCanvasElement into a CanvaImageBlob.

Usage

1
const { imageHelpers } = window.canva;
2
const canva = window.canva.init();
3
4
canva.onReady(async () => {
5
// Create an HTMLCanvasElement
6
const canvas = document.createElement("canvas");
7
8
// Convert an HTMLCanvasElement into a CanvaImageBlob
9
const image = await imageHelpers.fromCanvas("image/jpeg", canvas);
10
11
// Do something with the result
12
console.log(image);
13
});
Copied!

Parameters

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.

Returns

Promise<CanvaImageBlob>
Last modified 1mo ago
Copy link