Skip to content

editorGlobalsImageUtils

Class: ImageUtils

Hierarchy

  • ImageUtils

Index

Methods

Methods

Static Private _cropParamsForPicture

_cropParamsForPicture(image: Jimp, aspectRatio: number): object

Defined in src/util/ImageUtils.ts:47

Calculates the top left corner plus width and height of the crop window needed to crop the given image to the given aspect ratio.

Parameters:

Name Type Description
image Jimp Jimp image to crop
aspectRatio number Aspect ratio as number width/height

Returns: object

Object with topLeftX, topLeftY, width and height

  • height: number

  • topLeftX: number

  • topLeftY: number

  • width: number


Static cropAndResize

cropAndResize(image: Jimp, aspectRatio: number, newWidth: number): Promise‹Blob›

Defined in src/util/ImageUtils.ts:30

Crops a given image to the given aspect ratio (centered, preserving smaller dimension) and resizes it to the given width.

Parameters:

Name Type Description
image Jimp Jimp image to crop
aspectRatio number Aspect ratio as number width/height
newWidth number Desired width of the resulting image in px

Returns: Promise‹Blob›

Promise to a Blob with the resulting image and mimetype "image/jpeg"


Static roundImageBuffer

roundImageBuffer(imageBuffer: ArrayBuffer, maskBuffer?: ArrayBuffer): Promise‹ArrayBuffer›

Defined in src/util/ImageUtils.ts:6

Parameters:

Name Type
imageBuffer ArrayBuffer
maskBuffer? ArrayBuffer

Returns: Promise‹ArrayBuffer›