Class: PhotoEditorSDK

PhotoEditorSDK

The main SDK class which handles rendering and manages operations.

new PhotoEditorSDK(preferredRenderer, options)

sdk/core/sdk.js, line 57

Creates a PhotoEditorSDK instance

Name Type Default Description
preferredRenderer String webgl optional

webgl or canvas

options Object
Name Type Default Description
license String

Your license

image Image optional

The image that should be rendered

renderMode String dynamic optional

dynamic or export

versionCheck Boolean true optional

Should a version check be performed?

displayWelcomeMessage Boolean true optional

Should a welcome message be printed in the console?

transparent Boolean false optional

Should the canvas background be transparent?

canvas HTMLCanvasElement optional

The canvas element the SDK should render to

zoom Number 1 optional

The zoom level. Only available in dynamic mode

spriteScale Number 1 optional

The output sprite's scale. Only available in dynamic mode

logLevel String warn optional

trace, info, warn, error or log

pixelRatio Number 1 optional

If none is given, PhotoEditorSDK automatically

crossOrigin String 'anonymous' optional

'anonymous', 'use-credentials' or 'none' detects the current device's pixel ratio

smoothDownscaling Boolean false optional

Toggles smooth downscaling

smoothUpscaling Boolean false optional

Toggles smooth upscaling

Classes

Operation
Color
Configurable
EventEmitter
OperationsStack

Namespaces

Engine
Math
Operations
UI

Members

constantOptionTypeString

The available option types for classes inheriting PhotoEditorSDK.Configurable

Properties:
Name Type Description
NUMBER string
VECTOR2 string
COLOR_MATRIX string
COLOR string
ARRAY string
OBJECT string
STRING string
BOOLEAN string
CONFIGURABLE string
IMAGE string
FUNCTION string
TEXTURE string
ALL string

static,constantPhotoEditorSDK.exports.ImageFormatString

The available image types

Properties:
Name Type Description
PNG string

image/png

JPEG string

image/jpeg

static,constantPhotoEditorSDK.exports.RenderTypeString

The available render types

Properties:
Name Type Description
IMAGE string

image

DATAURL string

data-url

BUFFER string

buffer (Only supported by the Server SDK)

BLOB string

blob

MSBLOB string

ms-blob

staticPhotoEditorSDK.version

The current version of the SDK

constantRendererTypeString

The available renderer types

Properties:
Name Type Description
WEBGL string
CANVAS string

constantUniformTypeString

The available uniform types for WebGL shaders

Properties:
Name Type Description
SAMPLER2D string
INT string
INT1 string
FLOAT string
FLOAT1 string
FLOAT2 string
FLOAT_VECTOR2 string
FLOAT3 string
FLOAT4 string
MAT3 string
MAT3FV string
MAT4 string

Methods

_disposeTextures()

sdk/core/sdk.js, line 766

Dispose the flagged textures.

addOperation(operation)

sdk/core/sdk.js, line 528

Adds the given operation to the operations stack

Name Type Description
operation PhotoEditorSDK.Operation

createOperation(identifier, options, addToStack){PhotoEditorSDK.Operation}

sdk/core/sdk.js, line 511

Creates an operation with the given identifier

Name Type Default Description
identifier String
options Object {} optional
addToStack Boolean true optional
Returns:
Type Description
PhotoEditorSDK.Operation

dispose()

sdk/core/sdk.js, line 1073

Disposes the SDK

disposeTexture(texture)

sdk/core/sdk.js, line 759

Flag a texture for disposal at the end of the next render.

Name Type Description
texture PhotoEditorSDK.Engine.Texture

export(renderType, imageFormat, quality){Promise}

sdk/core/sdk.js, line 303

Exports the image with the given options. Result of the Promise is the exported image or data url.

Name Type Default Description
renderType PhotoEditorSDK.RenderType PhotoEditorSDK.RenderType.DATAURL optional

The output type

imageFormat PhotoEditorSDK.ImageFormat PhotoEditorSDK.ImageFormat.PNG optional

The output image format

quality Number 0.8 optional

The image quality, between 0 and 1

Returns:
Type Description
Promise

getCanvas(){HTMLCanvasElement}

sdk/core/sdk.js, line 837

Returns the canvas

Returns:
Type Description
HTMLCanvasElement

getContainer(){PhotoEditorSDK.Engine.Container}

sdk/core/sdk.js, line 861

Returns the container

Returns:
Type Description
PhotoEditorSDK.Engine.Container

getExif(){PhotoEditorSDK.Exif}

sdk/core/sdk.js, line 1016

Returns the Exif instance

Returns:
Type Description
PhotoEditorSDK.Exif [description]

getFinalDimensions(incorporateSpriteScale){PhotoEditorSDK.Math.Vector2}

sdk/core/sdk.js, line 557

Returns the final dimensions that the input image would have after all existing operations have been applied

Name Type Default Description
incorporateSpriteScale Boolean false

= false

Returns:
Type Description
PhotoEditorSDK.Math.Vector2

getImage(){Image}

sdk/core/sdk.js, line 751

Returns the image

Returns:
Type Description
Image

getInputDimensions(){PhotoEditorSDK.Math.Vector2}

sdk/core/sdk.js, line 546

Returns the initial image dimensions

Returns:
Type Description
PhotoEditorSDK.Math.Vector2

getInputTexture(){PhotoEditorSDK.Engine.Texture}

sdk/core/sdk.js, line 1032

Returns the input texture

Returns:
Type Description
PhotoEditorSDK.Engine.Texture

getOffset(){PhotoEditorSDK.Math.Vector2}

sdk/core/sdk.js, line 906

Returns the rendering offset

Returns:
Type Description
PhotoEditorSDK.Math.Vector2

getOperations(){Array.<Operation>}

sdk/core/sdk.js, line 890

Returns the available operations

Returns:
Type Description
Array.<Operation>

getOperationsStack(){PhotoEditorSDK.OperationsStack}

sdk/core/sdk.js, line 869

Returns the operation stack

Returns:
Type Description
PhotoEditorSDK.OperationsStack

getOptions(){Object}

sdk/core/sdk.js, line 1024

Returns the options

Returns:
Type Description
Object

getOutputDimensions(incorporateSpriteScale){Vector2}

sdk/core/sdk.js, line 578

Returns the current sprite dimensions

Name Type Default Description
incorporateSpriteScale Boolean false

= false

Returns:
Type Description
Vector2

getOutputTextureDimensions(incorporateSpriteScale){Vector2}

sdk/core/sdk.js, line 589

Returns the dimensions of the output texture

Name Type Default Description
incorporateSpriteScale Boolean false

= false

Returns:
Type Description
Vector2

getPixelRatio(){Number}

sdk/core/sdk.js, line 1008

Returns the pixel ratio

Returns:
Type Description
Number

getRenderer(){PhotoEditorSDK.Engine.BaseRenderer}

sdk/core/sdk.js, line 898

Returns the renderer

Returns:
Type Description
PhotoEditorSDK.Engine.BaseRenderer

getRenderMode(){String}

sdk/core/sdk.js, line 927

Returns the current render mode

Returns:
Type Description
String

getRotation()

sdk/core/sdk.js, line 1057

Returns the current rotation

getSprite(){PhotoEditorSDK.Engine.Sprite}

sdk/core/sdk.js, line 853

Returns the sprite

Returns:
Type Description
PhotoEditorSDK.Engine.Sprite

getSpriteScale(){Number}

sdk/core/sdk.js, line 990

Returns the output sprite's scale

Returns:
Type Description
Number

getTextureQuality(){Number}

sdk/core/sdk.js, line 961

Returns the texture quality

Returns:
Type Description
Number

getZoom(){Number}

sdk/core/sdk.js, line 943

Returns the zoom level

Returns:
Type Description
Number

hasChanges(){Boolean}

sdk/core/sdk.js, line 1065

Check if the OperationsStack has changes

Returns:
Type Description
Boolean

hasImage(){Boolean}

sdk/core/sdk.js, line 743

Checks if an image is provided

Returns:
Type Description
Boolean [description]

registerOperations(operations)

sdk/core/sdk.js, line 490

Registers the given operations

Name Type Description
operations Array.<PhotoEditorSDK.Operation>

removeOperation(operation)

sdk/core/sdk.js, line 536

Removes the given operation from the operations stack

Name Type Description
operation PhotoEditorSDK.Operation

render(renderOutput){Promise}

sdk/core/sdk.js, line 329

Renders the current image to the canvas

Name Type Default Description
renderOutput Boolean true

= true

Returns:
Type Description
Promise

reset()

sdk/core/sdk.js, line 659

Resets all custom and selected operations

resizeTo(dimensions)

sdk/core/sdk.js, line 652

Resizes the renderer to the given dimensions

Name Type Description
dimensions PhotoEditorSDK.Math.Vector2

setAllOperationsToDirty(dimensionsChanged)

sdk/core/sdk.js, line 500

Sets all operations in the stack to dirty

Name Type Default Description
dimensionsChanged Boolean false

= false

setCanvas(canvas)

sdk/core/sdk.js, line 845

Sets the canvas

Name Type Description
canvas HTMLCanvasElement

setImage(image, exif, dimensions)

sdk/core/sdk.js, line 780

Sets the image and parses the exif data

Name Type Default Description
image Image
exif PhotoEditorSDK.Exif null optional
dimensions PhotoEditorSDK.Math.Vector2 null optional

setInputTexture(texture)

sdk/core/sdk.js, line 829

Set the input texture for this SDK as an alternative to passing in an image

Name Type Description
texture PhotoEditorSDK.Engine.Texture

setOffset(offset, y)

sdk/core/sdk.js, line 915

Sets the rendering offset

Name Type Description
offset PhotoEditorSDK.Math.Vector2 | Number
y Number

setOperationsStack(operationsStack)

sdk/core/sdk.js, line 877

Sets the operations stack

Name Type Description
operationsStack PhotoEditorSDK.OperationsStack

setRenderMode(renderMode)

sdk/core/sdk.js, line 935

Sets the render mode

Name Type Description
renderMode String

setRotation(rotation)

sdk/core/sdk.js, line 1050

Sets the rotation to the given value

Name Type Description
rotation Number

setSmoothDownscaling(smoothDownscaling)

sdk/core/sdk.js, line 1040

Sets the smooth downscaling flag for the output sprite

Name Type Description
smoothDownscaling Boolean

setSpriteScale(spriteScale)

sdk/core/sdk.js, line 998

Sets the sprite scale to the given value

Name Type Description
spriteScale Number

setTextureQuality(textureQuality)

sdk/core/sdk.js, line 973

Sets the texture quality

Name Type Description
textureQuality Number

setZoom(zoom)

sdk/core/sdk.js, line 951

Sets the zoom level

Name Type Description
zoom Number