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

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

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.
Last modified 1mo ago