Skip to main content

sdk.imageapi

Home > @kittl/sdk > ImageAPI

ImageAPI interface

API for adding and updating images in the design.

Signature:

export interface ImageAPI 

Methods

Method

Description

addImage(params, opts)

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

updateImage(params, opts)

Updates an existing image object in the design by updating its properties.

This method allows for in-place modification of existing image objects without recreating them. Currently supports position updates (left and top coordinates), with the ability to extend to other properties in the future.

**Update Behavior:** - Only specified properties are updated; all other properties remain unchanged - Position updates are applied directly to the existing object - Changes are tracked in the patch system for undo/redo functionality - Object maintains its current board assignment and hierarchy