Image Editing

Generated reference for the iPrintessApi methods tagged #ai-api:images-editing in printess-editor.d.ts. Custom types referenced below (parameter and return shapes) are documented on the Types reference.

allowImageDistribution

allowImageDistribution(): boolean

check number of distributable image boxes if greater than 1 return true

Returns: boolean

allowSimpleImageBorder

allowSimpleImageBorder(): boolean

Returns true if the image border button should be shown in the buyer UI.

Returns: boolean

alwaysRenderCroppedImage

alwaysRenderCroppedImage(): boolean

Tells to render a new image after cropping even with no rotation

Returns: boolean

assignImageByIdToFrameByNameOrTitle

assignImageByIdToFrameByNameOrTitle(imageId: string, frameNameOrTitle: string): Promise<void>

Assign a specified image to frames. The image is selected by id. You can specify the search scope where to look for frames.

Parameter Type Description
imageId string The id of the image you want to assign.
frameNameOrTitle string The JsName or Title of the frame

Returns: Promise<void>

assignImageByIdToFramesWithClass

assignImageByIdToFramesWithClass(imageId: string, className: string, searchScope: "spread" | "document" | "template"): Promise<void>

Assign a specified image to frames. The image is selected by id. You can specify the search scope where to look for frames.

Parameter Type Description
imageId string The id of the image you want to assign.
className string The class name to search for in frames.
searchScope “spread” | “document” | “template” The scope to search frames in.

Returns: Promise<void>

assignImageToNextPossibleFrame

assignImageToNextPossibleFrame(imgId: string, origin?: "upload" | "thumb-click"): Promise<boolean>

If no selection is present this call finds the first unassigned image and assigns it If all images are already assigned it takes the first image and re-assigns it

Parameter Type Description
imgId string
origin? “upload” | “thumb-click”

Returns: Promise<boolean>

assignImageToSelectionOrInsertAsNewFrame

assignImageToSelectionOrInsertAsNewFrame(imgId: string): Promise<void>

Will use current selection or insert a new frame on the spread.

Parameter Type Description
imgId string Existing image-id to assign

Returns: Promise<void>

assingImageByIdToFramesWithClass

This method is deprecated.

assingImageByIdToFramesWithClass(imageId: string, className: string, searchScope: "spread" | "document" | "template"): Promise<void>

Assign a specified image to frames. The image is selected by id. You can specify the search scope where to look for frames.

Parameter Type Description
imageId string The id of the image you want to assign.
className string The class name to search for in frames.
searchScope “spread” | “document” | “template” The scope to search frames in.

Returns: Promise<void>

assingImageByNameToSelection

This method is deprecated.

assingImageByNameToSelection(imageName: string, options: null | { placement?: "fit" | "fill", horizontalFocalPoint?: number, verticalFocalPoint?: number, onlyAssignToAllowedImages?: boolean }): Promise<boolean>

Assigns image found by name to single selected frame only.

Parameter Type Description
imageName string Name of the image to assign
options null | { placement?: “fit” | “fill”, horizontalFocalPoint?: number, verticalFocalPoint?: number, onlyAssignToAllowedImages?: boolean } Optional placement (“fit” | “fill”), focal point and onlyAssignToAllowedImages flag; may be null

Returns: Promise<boolean>

canScale

canScale(propertyId: string): boolean

Check if image zoom is allowed

Parameter Type Description
propertyId string

Returns: boolean

cropImage

cropImage(propertyId: string, box: { left: number, top: number, width: number, height: number }): Promise<iExternalImage | null>

Creates a new cropped image and assigns it to the passed form-field. Takes the currently assigned image as master

Parameter Type Description
propertyId string id of a form-field-property (type of image-id) pointing to a valid image
box { left: number, top: number, width: number, height: number } all box coordinates are expected to be in the range of 0 to 1

Returns: Promise<iExternalImage | null>

currentSelectionAllowsImageUpload

currentSelectionAllowsImageUpload(): boolean

returns true if a single frame with buyer side image upload allow is selected

Returns: boolean

distributeImages

distributeImages(force?: boolean): Promise<Array<string>>

automatically distribute all non used uploaded images to frames which have not been assigned yet. Returns a list of all applied image-ids. Force needs to be true if “manual” distribution is active

Parameter Type Description
force? boolean

Returns: Promise<Array<string>>

getImageBordersOnCurrentSpread

getImageBordersOnCurrentSpread(): { innerWidth: number, outerWidth: number, innerColor: string, outerColor: string }

Retrieve image borders on current spread

Returns: { innerWidth: number, outerWidth: number, innerColor: string, outerColor: string }

getImageByClassName

getImageByClassName(className: string): iExternalImage & { placement: "fit" | "fill" } | null

Returns first iExternalImage found for class name

Parameter Type Description
className string

Returns: iExternalImage & { placement: “fit” | “fill” } | null

getImageByFrameName

getImageByFrameName(frameNameOrTitle: string): iExternalImage & { placement: "fit" | "fill" } | null

Returns first iExternalImage found for frame jsName or Title

Parameter Type Description
frameNameOrTitle string jaName or Title of a frame. JsName is checked first.

Returns: iExternalImage & { placement: “fit” | “fill” } | null

getImageFrameInfos

getImageFrameInfos(propertyId: string): iExternalImageFrameInfos

Returns extended information about image and its frame

Parameter Type Description
propertyId string The property-id of the image frame

Returns: iExternalImageFrameInfos

getImageNameByClassName

This method is deprecated.

getImageNameByClassName(className: string): iExternalImage & { placement: "fit" | "fill" } | null

Returns first iExternalImage found for class name

Parameter Type Description
className string

Returns: iExternalImage & { placement: “fit” | “fill” } | null

getImagesFromCurrentSpread

getImagesFromCurrentSpread(excludeSelectedFrames: boolean, skipDefaultImages: boolean, onlyFramesWithLayoutOrigin: boolean): iExternalImage[]

Returns all images placed on the current spread

Parameter Type Description
excludeSelectedFrames boolean
skipDefaultImages boolean
onlyFramesWithLayoutOrigin boolean

Returns: iExternalImage[]

hasStaticImageFilters

hasStaticImageFilters(): boolean

Indicate if the template has static image filters to display, like AI-enhancement for example

Returns: boolean

imageDistributionMode

imageDistributionMode(): "distributeOnUpload" | "distributeToAllFrames" | "distributeManually"

current image distribution mode set on template level

Returns: “distributeOnUpload” | “distributeToAllFrames” | “distributeManually”

insertImageFrame

insertImageFrame(imageId: string): Promise<boolean>

Will insert a new image frame on the current spread as a sticker; Returns false if image was not found.

Parameter Type Description
imageId string Existing image-id to assign

Returns: Promise<boolean>

resetImageFilters

resetImageFilters(
    propertyId: string,
    imageMeta?: {
      brightness?: number,
      sepia?: number,
      invert?: number,
      hueRotate?: number,
      contrast?: number,
      vivid?: number
    }): Promise<void>

Resets all image filters (meta-values) of an image-property to default

Parameter Type Description
propertyId string
imageMeta? { brightness?: number, sepia?: number, invert?: number, hueRotate?: number, contrast?: number, vivid?: number } optional parameter, can be used to set all image-filters to specific values.

Returns: Promise<void>

rotateAndCropImage

rotateAndCropImage(propertyId: string, rotation: iExternalImageRotation): Promise<iExternalImage | null>

Rotates image with any given angle.

Parameter Type Description
propertyId string
rotation iExternalImageRotation

Returns: Promise<iExternalImage | null>

rotateImage

rotateImage(propertyId: string, angle: "0" | "90" | "180" | "270", crop?: { ws: number, hs: number, px: number, py: number }): Promise<iExternalImage | null>

Rotates an image by 90deg and saves the result as new image and assigns rotated image to frame automatically.

Parameter Type Description
propertyId string
angle “0” | “90” | “180” | “270”
crop? { ws: number, hs: number, px: number, py: number }

Returns: Promise<iExternalImage | null>

setImageBordersOnCurrentSpread

setImageBordersOnCurrentSpread(b: { innerWidth?: number, outerWidth?: number, innerColor?: string, outerColor?: string }, onlySplitterFrames: boolean): Promise<void>

Sets image inner and outer border for all images on current spread Image borders are only rendered for non images without effects or warps or path-geometrie

Parameter Type Description
b { innerWidth?: number, outerWidth?: number, innerColor?: string, outerColor?: string }
onlySplitterFrames boolean

Returns: Promise<void>

setImageMetaProperty

setImageMetaProperty(propertyId: string, name: "scale" | "sepia" | "brightness" | "saturate" | "invert" | "contrast" | "grayscale" | "vivid" | "hueRotate", value: string | number): Promise<void>

Method to set an image meta-property Set the image itself via setProperty()

Parameter Type Description
propertyId string
name “scale” | “sepia” | “brightness” | “saturate” | “invert” | “contrast” | “grayscale” | “vivid” | “hueRotate”
value string | number

Returns: Promise<void>

setImagePlacement

setImagePlacement(which: "fit" | "fill", propertyId?: string): Promise<void | (iExternalImageScaleHints & { scale: number })>

Sets image placement based on selection, can only handle a single selected image for now.

Parameter Type Description
which “fit” | “fill”
propertyId? string TODO: Support for propertyId will follow

Returns: Promise<void | (iExternalImageScaleHints & { scale: number })> — Scale hints including the applied scale, when available

showCropOverlayButtons

showCropOverlayButtons(): boolean

Returns whether UI should show buttons for cropping in the Crop+Rotate overlay

Returns: boolean

showImageDistributionButton

showImageDistributionButton(): boolean

Tells UI to always show image distribution button.

Returns: boolean

transferImageByFrameName

transferImageByFrameName(fromBoxName: string, toBoxName: string, options?: { placement: "fit" | "fill", horizontalFocalPoint: number, verticalFocalPoint: number }): Promise<boolean>

Transfers the uploaded image from one image frame to another. Also applies assign-actions if applicable

Parameter Type Description
fromBoxName string Name of from frame
toBoxName string Name of to frame
options? { placement: “fit” | “fill”, horizontalFocalPoint: number, verticalFocalPoint: number } Optional placement (“fit” | “fill”) and focal point

Returns: Promise<boolean>