Image Upload

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

addSerializedImage

addSerializedImage(imageJson: string, assignToFrameOrNewFrame?: boolean): Promise<iExternalImage>
Parameter Type Description
imageJson string
assignToFrameOrNewFrame? boolean

Returns: Promise<iExternalImage>

allowImageDownload

allowImageDownload(): boolean

Tells UI to display download button on image thumbnail.

Returns: boolean

allowOnlyVectorImageUpload

allowOnlyVectorImageUpload(): boolean

Returns if buyer is only allowed to upload vector (svg) files

Returns: boolean

allowPdfUpload

allowPdfUpload(): boolean

Returns if buyer is allowed to upload pdf files

Returns: boolean

allowSvgUpload

allowSvgUpload(): boolean

Returns if buyer is allowed to upload svg files

Returns: boolean

createAwsUploaderProvider

createAwsUploaderProvider(uploadEndpoint: string, serveEndpoint?: string, keyGenerator?: (fileName: string, fileHash: string) => string): AwsUploadProvider

Creates an upload provider which uploads buyer files directly to an AWS S3 bucket. Pass the result to setUploadProvider().

Parameter Type Description
uploadEndpoint string The target address to send the upload form data to. E.g. https://your-bucket.s3.eu-central-1.amazonaws.com/
serveEndpoint? string The url the files are served from. This can differ from the upload endpoint to make CDN distribution possible. E.g. https://mycloudfrontid.amazonaws.com/
keyGenerator? (fileName: string, fileHash: string) => string The method to generate the S3 key. The built-in one just makes sure that the file name is unique per session.

Returns: AwsUploadProvider

createExternalImageUploadChannel

createExternalImageUploadChannel(): Promise<{ qr: HTMLImageElement, channelId: string }>

get a QR Code for uploading images on mobile phone Pass the returned channelId to startExternalImagePolling() to receive the uploaded images.

Returns: Promise<{ qr: HTMLImageElement, channelId: string }>

deleteImages

deleteImages(images: Array<iExternalImage>): number

delete buyer uploaded images that are not in use Returns the number of successfully deleted images.

Parameter Type Description
images Array<iExternalImage> array of images to be deleted

Returns: number

getAllImages

getAllImages(): Array<iExternalImage>

Returns all buyer uploaded images including information if the image is in use

Returns: Array<iExternalImage>

getDirectImageMetadataFinalizationPromises

getDirectImageMetadataFinalizationPromises(): Set<Promise<any>>

When using direct upload, this will return all the image meta data finalization promises.

Returns: Set<Promise<any>> — The currently pending metadata promises for direct upload.

getImageByName

getImageByName(name: string): iExternalImage | null

Looks up image by name - case insensitive

Parameter Type Description
name string

Returns: iExternalImage | null

getImageGroups

getImageGroups(propertyId?: string): Array<string>

Returns all available image groups

Parameter Type Description
propertyId? string id of property which shows the image list

Returns: Array<string>

getImageName

getImageName(jsName: string): string | null

Returns image name by js-name of frame.

Parameter Type Description
jsName string

Returns: string | null

getImages

getImages(propertyId?: string): Array<iExternalImage>

If property is empty it returns the list of buyer uploaded images.

Parameter Type Description
propertyId? string id of property which shows the image list

Returns: Array<iExternalImage>

Used in these examples:

getImageThumbFitProperty

getImageThumbFitProperty(): "fill" | "fit"

Tells UI to resize an image in the “My Photos” tab to fit within the bounds of its container with no cropping (“fit”) or to expand an image to fill the whole container potentially with cropping (“fill”)

Returns: “fill” | “fit”

getPendingImageUploads

getPendingImageUploads(): Set<Promise<any>>

When using direct upload, this will return all the pending image upload promises. You can use Promise.any() to show some nice progress.

Returns: Set<Promise<any>> — The currently pending upload promises for direct upload.

getPendingImageUploadsCount

getPendingImageUploadsCount(): number

When using direct upload, this will return the count of outstanding image uploads.

Returns: number

getSelectedImageRecommendedSize(): null | { pxWidth: number, pxHeight: number }

Returns the recommended upload size of the currently selected image

Returns: null | { pxWidth: number, pxHeight: number }

getSerializedImage

getSerializedImage(imageId: string): string | null
Parameter Type Description
imageId string

Returns: string | null

getUploadedImagesCount

getUploadedImagesCount(): number

Returns image-count in “Buyer Upload” folder.

Returns: number

getUploadsInProgress

getUploadsInProgress(): number

When using direct upload, this returns the count of upload processes.

Returns: number — The number of upload processes.

importImageFromUrl

importImageFromUrl(url: string, assignToFrameOrNewFrame?: boolean, propertyId?: string): Promise<iExternalImage | null>

Imports a single image to Printess and can auto assign this image

Parameter Type Description
url string The url to the image you want to import to Printess.
assignToFrameOrNewFrame? boolean Default is true. Assign this image to the current frame, or create a new frame in case none is selected.
propertyId? string (optional) if a propertyId is submitted, printess will assign the image to that particular frame

Returns: Promise<iExternalImage | null>

Used in these examples:

importImagesFromExternal

importImagesFromExternal(images: iImage[], assignToFrameOrNewFrame?: boolean): Promise<iExternalImage[]>

Imports the given external images and optionally assigns them to frames.

Parameter Type Description
images iImage[]
assignToFrameOrNewFrame? boolean The default value is false

Returns: Promise<iExternalImage[]>

importUserUploadedImages

importUserUploadedImages(shopUserId?: string, basketId?: string): Promise<iExternalImage[]>

Imports up to 50 previously uploaded user images. You can either provide the shopUserId and basketId to load images uploaded in this basket session, or only provide the shopUserId to load the images from the user. Please make sure you are using non guessable shop user and basket ids.

Parameter Type Description
shopUserId? string
basketId? string

Returns: Promise<iExternalImage[]>

Used in these examples:

isImageInUse

isImageInUse(imageId: string): boolean

Returns if a specific image is used in buyer editable frame.

Parameter Type Description
imageId string Id of image to test

Returns: boolean

setShopInfo

setShopInfo(shopUserId: string, basketId: string): void

Associates buyer uploads with your shop user and basket session, so previously uploaded images can be re-imported later via importUserUploadedImages().

Parameter Type Description
shopUserId string Your shop user id. You can provide this to assign uploaded images to this user and load it later on.
basketId string The basket id for this session. You can load images later on with this id.

Returns: void

setUploadProvider

setUploadProvider(provider: UploadProvider): void

Sets the upload provider used for buyer file uploads (images and fonts).

Parameter Type Description
provider UploadProvider The new upload provider to use.

Returns: void

showImageCaptions

showImageCaptions(): boolean

Tells UI to show the image name under every image thumbnail.

Returns: boolean

showImagePreviewOverlay

showImagePreviewOverlay(): boolean

Tells UI to show the image preview when hovering image thumbnail.

Returns: boolean

showMobileUploadButton

showMobileUploadButton(): boolean

Tells UI to display upload button for image upload from mobile phone.

Returns: boolean

showSearchBar(): boolean

Returns if buyer ui should display the search bar for searching through images

Returns: boolean

startExternalImagePolling

startExternalImagePolling(channeldId: string, isHandwriting?: boolean, cancellationToken?: StoppingToken): void

check for images uploaded from phone

Parameter Type Description
channeldId string The channel id returned by createExternalImageUploadChannel()
isHandwriting? boolean
cancellationToken? StoppingToken

Returns: void

uploadAndDistributeImages

uploadAndDistributeImages(files: FileList | null, propertyId: string, progressCallback?: (percent: number, state: "upload" | "optimization") => void, isHandwritingImage?: boolean): Promise<iExternalImage[]>

Uploads one or many images to Printess and auto assigns the first image if an image frame is selected If no frame is selected it distributes to the next possible frame or automatically distributes all images depending on the template settings

Parameter Type Description
files FileList | null
propertyId string Auto assigns the first image to a specific frame identified via property Id. Pass “NONE” to NOT assign the image.
progressCallback? (percent: number, state: “upload” | “optimization”) => void
isHandwritingImage? boolean Toggle the current textframe to handwriting mode und assigns image

Returns: Promise<iExternalImage[]>