Class: ImageResource


Resource type for HTMLImageElement.

new PIXI.resources.ImageResource (source, options)

Name Type Description
source HTMLImageElement | string

image source or URL

options object optional
Name Type Default Description
autoLoad boolean true optional

start loading process

createBitmap boolean PIXI.settings.CREATE_IMAGE_BITMAP optional

whether its required to create a bitmap before upload

crossorigin boolean true optional

Load image using cross origin


Premultiply image alpha in bitmap



_height number protected inherited overrides

Internal height of the resource

_width number protected inherited overrides

Internal width of the resource

alphaMode PIXI.ALPHA_MODES | null readonly

Controls texture alphaMode field Copies from options Default is null, copies option from baseTexture

bitmap ImageBitmap

The ImageBitmap element created for HTMLImageElement

Default Value:
  • null

createBitmap boolean

If capable, convert the image using createImageBitmap API

Default Value:

destroyed boolean readonly inherited

If resource has been destroyed

Default Value:
  • false

height number readonly inherited

The height of the resource.

internal boolean protected inherited

true if resource is created by BaseTexture useful for doing cleanup with BaseTexture destroy and not cleaning up resources that were created externally.

premultiplyAlpha boolean Deprecated : since 5.2.0 readonly


preserveBitmap boolean

If the image should be disposed after upload

Default Value:
  • false

source HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | SVGElement readonly inherited

The source element

url string

URL of the image source

valid boolean readonly inherited

Has been validated

width number readonly inherited

The width of the resource.


PIXI.resources.ImageResource.test (source)boolean static

Used to auto-detect the type of resource.

Name Type Description
source string | HTMLImageElement

The source object

Type Description
boolean true if source is string or HTMLImageElement

bind (baseTexture) inherited

Bind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

Call when destroying resource, unbind any BaseTexture object before calling this method, as reference counts are maintained internally.

dispose () protected inherited overrides

Clean up anything, this happens when destroying is ready.

load (createBitmap)Promise.<void> overrides

returns a promise when image will be loaded and processed

Name Type Description
createBitmap boolean optional

whether process image into bitmap

Type Description

process ()Promise.<void>

Called when we need to convert image into BitmapImage. Can be called multiple times, real promise is cached inside.

Type Description
Promise.<void> cached promise to fill that bitmap

resize (width, height) inherited

Trigger a resize event

Name Type Description
width number

X dimension

height number

Y dimension

style (renderer, baseTexture, glTexture)boolean inherited

Set the style, optional to override

Name Type Description
renderer PIXI.Renderer

yeah, renderer!

baseTexture PIXI.BaseTexture

the texture

glTexture PIXI.GLTexture

texture instance for this webgl context

Type Description
boolean true is success

unbind (baseTexture) inherited

Unbind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

Checks if source width/height was changed, resize can cause extra baseTexture update. Triggers one update in any case.

upload (renderer, baseTexture, glTexture)boolean overrides

Upload the image resource to GPU.

Name Type Description
renderer PIXI.Renderer

Renderer to upload to

baseTexture PIXI.BaseTexture

BaseTexture for this resource

glTexture PIXI.GLTexture

GLTexture to use

Type Description
boolean true is success