Getting Started

​ ​Welcome

Blitline Job

Job Response

Job Options

Functions

Polling and Postbacks

Gotchas

Development Recommendations

Service Limits

Examples List

List of Available Functions

Output Options

S3 Destination

IAM Users

S3 Signed Url

Azure Destination

FTP Destination

Other Service Signed Urls

CDN

Advanced

Metadata

Colorspace

Color Extraction

Static IPs

Signed Jobs

Formats

Pipelines

Image Optimization

Smart Image

PDF

Fonts

Subimage

Special (Non-Image) Processing

AWS Rekognition/Facial Recognition

Apache Tika

Vector Processing

Animated GIFs

Screenshots of Websites

IM Scripts

Video Keyframes

Zipping

​ ​Trancoding Video Presets

​ ​Video Transcoding

Functions

Updated a month ago ​by Blitline Support

Functions are the operations that can be performed on images.

You can have 1 or more functions, and you can pipeline functions so that the output of 1 function is the input to the next function.

A complete list of functions can be found here

You can also find a Prezi  visual presentation about how Blitline functions work here

HOW DO FUNCTIONS WORK?

Functions have a name node and the have a params node. Much like functions in a programming language, the params are fed into the function. Many params are optional and have default values.

A typical function looks like this:

{
    "name":"annotate",
    "params":{
        "text":"my_text",
        "color":"#ffffff"
    }
}

OUTPUTTING IMAGES

Once a function has been completed on an image, you can set a location to save the image. Typically, this is your S3 or Azure location (but blitline will default to it’s own temporary bucket if no destination is given).

When you save an image, you must give it an image_identifier which is how this output image will be referred to in later JSON interaction. An image_identifier is just a name you give to an image, Blitline only cares that it exists and doesn’t care about it’s content.

To output an image after a function has completed just add a save node to the function node. For example:

{
    "name":"annotate",
    "params":{
        "text":"my_text",
        "color":"#ffffff"
    },
    "save" : {
        "image_identifier" : "my_annotated_image",
        "s3_destination" : {
            "key" : "my_key/to_my_image/image.png",
            "bucket" : "my_s3_bucket"
        }
    }
}

In this example we have a save field which has an image-identifier as well as an s3_destinationdefined. The s3_destination simply contains an s3 key and bucket. You will need to setup S3 permissions to allow Blitline to write to your bucket.

CHAINING FUNCTIONS

A common scenario is that you may want to chain functions together, such as annotating an image, and then resizing it to a smaller thumbnail. You can easily accomplish this by adding functions inside of other functions. For example:

{
    "name": "annotate",
    "params": {
        "text": "my_text",
        "color": "#ffffff"
    },
    "save": {
        "image_identifier": "my_annotated_image",
        "s3_destination": {
            "key": "my_key/to_my_image/image.png",
            "bucket": "my_s3_bucket"
        }
    },
    "functions": [
        {
            "name": "resize_to_fit",
            "params": {
                "width": 300
            },
            "save": {
                "image_identifier": "my_annotated_resized_thumbnail",
                "s3_destination": {
                    "key": "my_key/to_my_image/image.png",
                    "bucket": "my_s3_bucket"
                }
            }
        }
    ]
}


In the example above, we see a new functions array inside the parent functions array node. This indicates that the parent function will be performed and the embedded function will be performed on the output of the parent functions


How did we do?