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

Usage

1
const { imageHelpers } = window.canva;
2
const canva = window.canva.init();
3
4
canva.onReady(async () => {
5
// Convert a data URL into a CanvaImageBlob
6
const image = await imageHelpers.fromDataUrl(
7
"image/jpeg",
8
"data:image/jpeg;base64,iVBORw0KGgoAA..."
9
);
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".
dataUrl
string
Yes
The data URL to convert into a CanvaImageBlob.

Returns

Promise<CanvaImageBlob>
Last modified 1mo ago
Copy link