The /image/optimize Robot

Our /image/optimize robot

Transloadit can resize, crop, and (auto-)rotate images, as well as watermark them or read & write meta-data.

The /image/optimize Robot reduces the size of images while maintaining the same visual quality.

The /image/optimize Robot's Parameters

Name Type Default Description
progressive Boolean false Interlaces the image if set to true, which makes the result image load progressively in browsers. Instead of rendering the image from top to bottom, the browser will first show a low-res blurry version of the image which is then quickly replaced with the actual image as the data arrives. This greatly increases the user experience, but comes at a loss of about 10% of the file size reduction.
preserve_meta_data Boolean true Specifies if the image's meta data should be preserved during the optimization, or not. If it is not preserved, the file size is even further reduced. This option is mandatory if you set png_tool to "pngquant"
fix_breaking_images Boolean true If set to true this parameter tries to fix images that would otherwise make the underlying tool error out and thereby break your Assemblies. This can sometimes result in a larger file size, though.

Example use cases featuring the /image/optimize robot

See the robot in action with some live demos and code samples right here on our website:

Only resize larger images when resizing files

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "large-files": {
      "use": ":original",
      "robot": "/file/filter",
      "accepts": [
        [
          "${file.meta.width}",
          ">",
          "2048"
        ],
        [
          "${file.meta.height}",
          ">",
          "2048"
        ]
      ],
      "condition_type": "or"
    },
    "smaller-files": {
      "use": ":original",
      "robot": "/file/filter",
      "accepts": [
        [
          "${file.meta.width}",
          "<=",
          "2048"
        ],
        [
          "${file.meta.height}",
          "<=",
          "2048"
        ]
      ],
      "condition_type": "or"
    },
    "large-resized": {
      "use": "large-files",
      "robot": "/image/resize",
      "resize_strategy": "fit",
      "width": 2048,
      "height": 2048
    },
    "smaller-resized": {
      "use": "smaller-files",
      "robot": "/image/resize",
      "resize_strategy": "fit",
      "width": "${file.meta.width}",
      "height": "${file.meta.height}"
    },
    "optimized": {
      "use": [
        "smaller-resized",
        "large-resized"
      ],
      "robot": "/image/optimize"
    },
    "exported": {
      "use": [
        "optimized",
        ":original"
      ],
      "robot": "/s3/store",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Reduce image file sizes by up to 80% without quality loss

Here you can see a quick example of the Assembly Instructions required to create this encoding pipeline. More information is available in the Live demo

{
 "steps": {
    "optimized": {
      "use": ":original",
      "robot": "/image/optimize",
      "result": true
    }
  }
}


Did you know?

You can easily combine Robots to create powerful workflows, unique to your business.

This is the power of Transloadit.