Skip to content

Module: image-utils

Image utilities APIs

npm install @self.id/image-utils

Type aliases

Dimensions

Ƭ Dimensions: Object

Type declaration

Name Type
height number
width number

LinkData

Ƭ LinkData: Object

Type declaration

Name Type
Hash string
Name string
Size number

SizeMode

Ƭ SizeMode: "contain" | "cover"


SizedImage

Ƭ SizedImage: Dimensions & { blob: Blob }

Functions

getDimensions

getDimensions(image, dimensions?, mode?): Dimensions

Parameters

Name Type Default value
image HTMLImageElement undefined
dimensions Dimensions DEFAULT_DIMENSIONS
mode SizeMode 'cover'

Returns

Dimensions


loadImage

loadImage(blob): Promise<HTMLImageElement>

Parameters

Name Type
blob Blob

Returns

Promise<HTMLImageElement>


resizeImageElement

resizeImageElement(type, image, dimensions?, mode?): Promise<SizedImage>

Parameters

Name Type
type string
image HTMLImageElement
dimensions? Dimensions
mode? SizeMode

Returns

Promise<SizedImage>


selectImageSource

selectImageSource(sources, dimensions, mode?): ImageMetadata

Parameters

Name Type Default value
sources ImageSources undefined
dimensions Dimensions undefined
mode SizeMode 'cover'

Returns

ImageMetadata


uploadFile

uploadFile(url, blob, fileName?): Promise<string>

Parameters

Name Type
url string
blob Blob
fileName? string

Returns

Promise<string>


uploadImage

uploadImage(url, file, sizes?): Promise<ImageSources>

Parameters

Name Type Default value
url string undefined
file File undefined
sizes Dimensions[] []

Returns

Promise<ImageSources>


uploadResizedImage

uploadResizedImage(url, type, image, dimensions?): Promise<ImageMetadata>

Parameters

Name Type
url string
type string
image HTMLImageElement
dimensions? Dimensions

Returns

Promise<ImageMetadata>