ImageScript()

new ImageScript()

Methods

async post(body) → {image|error}

Runs an ImageScript script.
Injected variables will be available in the global scope.

Parameters:
Name Type Description
body object

The POST body

Properties
Name Type Description
args object

Special arguments

Properties
Name Type Description
text string

The script to run

inject object.<string, (string|number)>

The variables to inject into the context.

Returns:
image | error -

The calculated image. Response headers prefixed X-ImageScript- contain info about memory and timings.

Example

An example POST body

{
    "args": {
        "text": "const image = Image.new(width, height, 0xff0000ff);",
        "inject": {
            "width": 512,
            "height": 256
        }
    }
}