Skip to main content

CreateImage

Creates an image with the parameters specified.

Syntax

expression.CreateImage(sImageSrc, nWidth, nHeight);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sImageSrcRequiredstringThe image source where the image to be inserted should be taken from (currently, only internet URL or Base64 encoded images are supported).
nWidthRequiredEMUThe image width in English measure units.
nHeightRequiredEMUThe image height in English measure units.

Returns

ApiImage

Example

Insert an image from a URL in a presentation.

// How do I add an image with specific dimensions to a slide in a presentation?

// Place an image on a slide by specifying its source and size in a presentation.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();
const shape = Api.CreateImage(
'https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png',
60 * 36000, 60 * 36000
);
slide.AddObject(shape);