Links

toImageElement

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

Usage

const { imageHelpers } = window.canva;
const canva = window.canva.init();
canva.onReady(async (opts) => {
// Convert a CanvaElement into a CanvaImageBlob
const image = await imageHelpers.fromElement(opts.element);
// Convert the CanvaImageBlob into an HTMLImageElement
const img = await imageHelpers.toImageElement(image);
// Do something with the result
console.log(img);
});

Parameters

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

Returns

Promise<HTMLImageElement>