ImageHelper

ImageHelper

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

Constructor

new ImageHelper()

Methods

(static) compositeCanvasTexture(object, widthopt, heightopt, txopt, tyopt, centeropt) → {PIXI.Texture}

Composite a canvas object by rendering it to a single texture

Parameters:
Name Type Attributes Description
object PIXI.DisplayObject

The object to render to a texture

width number <optional>

The desired width of the output texture

height number <optional>

The desired height of the output texture

tx number <optional>

A horizontal translation to apply to the object

ty number <optional>

A vertical translation to apply to the object

center boolean <optional>

Center the texture in the rendered frame?

Returns:

The composite Texture object

Type
PIXI.Texture

(async, static) createThumbnail(src, options) → {Promise.<object>}

Create thumbnail preview for a provided image path.

Parameters:
Name Type Description
src string | PIXI.DisplayObject

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

options object

Additional named options passed to the compositeCanvasTexture function

Returns:

The parsed and converted thumbnail data

Type
Promise.<object>

(async, static) pixiToBase64(target, type, quality) → {Promise.<string>}

Asynchronously convert a DisplayObject container to base64 using Canvas#toBlob and FileReader

Parameters:
Name Type Description
target PIXI.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:

A processed base64 string

Type
Promise.<string>

(static) textureToImage(texture, formatopt, qualityopt) → {string}

Extract a texture to a base64 PNG string

Parameters:
Name Type Attributes Description
texture PIXI.Texture

The texture object to extract

format string <optional>

Image format, e.g. "image/jpeg" or "image/webp".

quality number <optional>

JPEG or WEBP compression from 0 to 1. Default is 0.92.

Returns:

A base64 png string of the texture

Type
string