LottieImage

ImageOptions

export interface ImageOptions {
data?: ImageData;
fileName: string;
id: string;
parentAnimation?: LottieAnimationCommon[];
url?: string;
}
data?: ImageData

Image data of the image. Can be of type: string | ArrayBuffer | Blob

fileName: string

Mandatory file name of the image asset.

id: string

Mandatory id of the image asset.

parentAnimation?: LottieAnimation

The LottieAnimation to which belongs the LottieImage.

url?: string

Optional URL to the image.

Methods

Export and util methods

renameImage(newName: string): void

Renames the id and file name to newName.

async generatePhash(): Promise<string>

Returns a generated string of 1s and 0s resulting from the dhash algorithm if used on a browser environment, or the phash algorithm if used in a Node environment.

async toDataURL(): Promise<string>

Returns the image as a Base64 encoded string.

async toArrayBuffer(): Promise<ArrayBuffer>

Returns the image as an ArrayBuffer.

async toBlob(): Promise<Blob>

Returns the image as a Blob.

async distanceTo(imageToCompare: LottieImage): Promise<number>

Calculates the distance of hash values between the current LottieImage and imageToCompare.