Links

fromDataUrl

API reference for the "fromDataUrl" method.
Converts a data URL into a CanvaImageBlob.

Usage

const { imageHelpers } = window.canva;
const canva = window.canva.init();
canva.onReady(async () => {
// Convert a data URL into a CanvaImageBlob
const image = await imageHelpers.fromDataUrl(
"image/jpeg",
"data:image/jpeg;base64,iVBORw0KGgoAA..."
);
// Do something with the result
console.log(image);
});

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".
dataUrl
string
Yes
The data URL to convert into a CanvaImageBlob.

Returns

Promise<CanvaImageBlob>