Output Options

CDN

S3 Signed Url

S3 Destination

FTP Destination

Azure Destination

IAM Users

Other Service Signed Urls

Getting Started

Blitline Job

Welcome

Job Options

List of Available Functions

Examples List

Functions

Job Response

Polling and Postbacks

Service Limits

Development Recommendations

Gotchas

Advanced

Pipelines

Fonts

Smart Image

Static IPs

Formats

Colorspace

Color Extraction

PDF

Image Optimization

Metadata

Signed Jobs

Subimage

Special (Non-Image) Processing

Zipping

Trancoding Video Presets

Apache Tika

AWS Rekognition/Facial Recognition

Animated GIFs

Building Gifs or Videos from Images

Find Image on the Internet

Video Keyframes

Video Transcoding

Screenshots of Websites

IM Scripts

Vector Processing

Functions

Updated 11 months 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?