Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "geocortex/essentials/utilities/ImageUtilities"

Index

Functions

calculateAspectRatioFit

  • calculateAspectRatioFit(srcWidth: number, srcHeight: number, maxWidth: number, maxHeight: number): object
  • Conserve aspect ratio of the original image. Useful when shrinking/enlarging images to fit into a certain area.

    Parameters

    • srcWidth: number

      Source area width

    • srcHeight: number

      Source area height

    • maxWidth: number

      Maximum available width

    • maxHeight: number

      Maximum available height

    Returns object

    • height: number
    • width: number

getRawByteDataFromDataUri

  • getRawByteDataFromDataUri(uri: string): string
  • Get the raw byte data from a data uri.

    Parameters

    • uri: string

      The data uri.

    Returns string

resizeImage

  • resizeImage(source: HTMLImageElement | HTMLCanvasElement | string, width: number, height: number): Promise<string>
  • Resize a source image to the desired dimensions.

    Parameters

    • source: HTMLImageElement | HTMLCanvasElement | string

      Source HTMLImageElement, HTMLCanvasElement, or base64 data uri string of image.

    • width: number

      Desired width of the image.

    • height: number

      Desired height of the image.

    Returns Promise<string>

    A base64 png image.

resizeImageToMaxDimensions

  • resizeImageToMaxDimensions(source: HTMLImageElement | HTMLCanvasElement | string, maxWidth: number, maxHeight: number): Promise<string>
  • Resize a source image to the desired dimensions provided by a maximum width and height, while maintaining the aspect ratio of the original image.

    Parameters

    • source: HTMLImageElement | HTMLCanvasElement | string

      Source HTMLImageElement, HTMLCanvasElement, or base64 data uri string of image.

    • maxWidth: number
    • maxHeight: number

    Returns Promise<string>

    A base64 png image.