Links

getSize

API reference for the "getSize" method.
Gets the dimensions of a CanvaImageBlob.

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);
// Get the size of the CanvaImageBlob
const size = await imageHelpers.getSize(image);
// Do something with the result
console.log(size);
});

Parameters

Name
Type
Required
Description
image
CanvaImageBlob
Yes
The CanvaImageBlob to get the dimensions of.

Returns

Promise<Size>

Types

Size

Name
Type
Required
Description
width
number
Yes
Represents a width, in pixels.
height
number
Yes
Represents a height, in pixels.