sdk.imageapi.addimage
Home > @kittl/sdk > ImageAPI > addImage
ImageAPI.addImage() method
Adds a new image to the design with intelligent positioning and automatic scaling.
This method fetches the image dimensions, calculates optimal positioning, and intelligently places the image either on an existing artboard or creates a new floating board as needed. The image can be automatically scaled based on the current viewport zoom level.
**Positioning Behavior:** - When position is not provided: Image is centered in the current viewport - When absolute position (top, left) is provided: Image is placed at exact coordinates - When relative positioning is used: Image is positioned relative to screen or other elements
**Artboard Placement Logic:** - If target position overlaps with an existing artboard (≥50% overlap): Image is added to that artboard - If target position has no overlap or <50% overlap: Image is added to a new floating board - Floating boards are automatically created and sized to fit the image
Signature:
addImage(params: AddImageParams, opts?: DesignApiOptions): Promise<NormalizedIllustrationImageObject>;
Parameters
Parameter | Type | Description |
|---|---|---|
params | Configuration parameters for adding the image | |
opts | (Optional) Additional options for the design API operation |
Returns:
Promise<NormalizedIllustrationImageObject>
Promise that resolves to the created image object with all computed properties
Exceptions
When image source is invalid or cannot be loaded
When position parameters are malformed
When specified artboard ID doesn't exist