Options
All
  • Public
  • Public/Protected
  • All
Menu

A helper class to provide common functionality for working with Image objects

Hierarchy

  • ImageHelper

Index

Constructors

Methods

  • createThumbnail(src: any, options: { width: number; height: number; tx: number; ty: number; center: boolean; format: string; quality: number }): Promise<any>
  • Create thumbnail preview for a provided image path.

    Parameters

    • src: any

      The URL or display object of the texture to render to a thumbnail

    • options: { width: number; height: number; tx: number; ty: number; center: boolean; format: string; quality: number }

      Additional named options passed to the compositeCanvasTexture function

      • width: number
      • height: number
      • tx: number
      • ty: number
      • center: boolean
      • format: string
      • quality: number

    Returns Promise<any>

    The parsed and converted thumbnail data

  • hasImageExtension(src: string): boolean
  • Test whether a source file has a supported image extension type

    Parameters

    • src: string

      A requested image source path

    Returns boolean

    Does the filename end with a valid image extension?

  • compositeCanvasTexture(object: DisplayObject, [options]?: { width: number; height: number; tx: number; ty: number; center: boolean }): Texture
  • Composite a canvas object by rendering it to a single texture

    Parameters

    • object: DisplayObject

      The object to render to a texture

    • [options]: { width: number; height: number; tx: number; ty: number; center: boolean } = {}

      Options which configure the resulting texture

      • width: number
      • height: number
      • tx: number
      • ty: number
      • center: boolean

    Returns Texture

    The composite Texture object

  • textureToImage(texture: Texture, __namedParameters?: string): string
  • Extract a texture to a base64 PNG string

    Parameters

    • texture: Texture

      The texture object to extract

    • __namedParameters: string = {}

    Returns string

    A base64 png string of the texture

  • pixiToBase64(target: DisplayObject, type: string, quality: number): Promise<string>
  • Asynchronously convert a DisplayObject container to base64 using Canvas#toBlob and FileReader

    Parameters

    • target: DisplayObject

      A PIXI display object to convert

    • type: string

      The requested mime type of the output, default is image/png

    • quality: number

      A number between 0 and 1 for image quality if image/jpeg or image/webp

    Returns Promise<string>

    A processed base64 string

  • uploadBase64(base64: string, fileName: string, filePath: string, [options]?: { storage: string; type: string }): Promise<any>
  • Upload a base64 image string to a persisted data storage location

    Parameters

    • base64: string

      The base64 string

    • fileName: string

      The file name to upload

    • filePath: string

      The file path where the file should be uploaded

    • [options]: { storage: string; type: string } = {}

      Additional options which affect uploading

      • storage: string
      • type: string

    Returns Promise<any>

    A promise which resolves to the FilePicker upload response