toImageElement
API reference for the "toImageElement" method.
Converts a CanvaImageBlob into an HTMLImageElement.

Usage

1
const { imageHelpers } = window.canva;
2
const canva = window.canva.init();
3
4
canva.onReady(async (opts) => {
5
// Convert a CanvaElement into a CanvaImageBlob
6
const image = await imageHelpers.fromElement(opts.element);
7
8
// Convert the CanvaImageBlob into an HTMLImageElement
9
const img = await imageHelpers.toImageElement(image);
10
11
// Do something with the result
12
console.log(img);
13
});
Copied!

Parameters

Name
Type
Required
Description
image
CanvaImageBlob
Yes
The CanvaImageBlob to convert into an HTMLImageElement.

Returns

Promise<HTMLImageElement>
Last modified 1mo ago
Copy link