Options
All
  • Public
  • Public/Protected
  • All
Menu

dont-crop

Index

Functions

fitGradient

  • fitGradient(image: CanvasImageSource): string
  • Fits a linear gradient to an image

    remarks

    because of it's dependency on <canvas> this function only works in the browser. In nodejs use fitGradientToImageData directly instead.

    Parameters

    • image: CanvasImageSource

      the image to fit the gradient to Will be scaled down to at most 32x32. Must be loaded/complete.

    Returns string

    a string that can be used as a css gradient

fitGradientToImageData

  • fitGradientToImageData(imageData: ImageData): string
  • Fits a linear gradient to image data

    Parameters

    • imageData: ImageData

      the image data to fit the gradient to.

    Returns string

    a string that can be used as a css gradient.

getImageData

  • getImageData(image: CanvasImageSource, maxDimension: number | undefined): ImageData
  • Parameters

    • image: CanvasImageSource
    • maxDimension: number | undefined

    Returns ImageData

getPalette

  • getPalette(image: CanvasImageSource, numberOfColors?: number, fast?: boolean): string[]
  • Extract representative colors from an image.

    remarks

    because of it's dependency on <canvas> this function only works in the browser.

    • In nodejs use getPaletteFromImageData directly instead.

    Parameters

    • image: CanvasImageSource

      the image to extract the palette from. Must be loaded/complete.

    • numberOfColors: number = 4

      upper limit on the number of colors to be returned

    • fast: boolean = false

      if true the image will be downscaled to 64x64, 128x128 otherwise. The precise sizes used may change in the future.

    Returns string[]

    representative colors of the image ordered by importance (size of the cluster)

getPaletteFromImageData

  • getPaletteFromImageData(imageData: ImageData, numberOfColors?: number): string[]
  • Extract representative colors from image data.

    Parameters

    • imageData: ImageData

      image data to extract the colors from

    • numberOfColors: number = 4

      upper limit on the number of colors to be returned

    Returns string[]

    representative colors of the image ordered by importance (size of the cluster)

Generated using TypeDoc