Feature Request: Simple Math in Assemblies

Archived from the Transloadit support forum. Originally posted on October 21, 2013; details may be outdated, see our docs for current behavior. Original thread

It would be REALLY useful to be able to do something like this:

"steps": {
   "add-20px-border": {
      "robot": "/image/resize",
      "resize_strategy": "pad",
      "zoom": false,
      "width": "${file.meta.width}+40",
      "height": "${file.meta.height}+40"
   }
}

Currently the file.meta vars actually get replaced, but the result doesn’t get evaluated as an arithmetic expression, throwing a convert error instead:

convert: invalid argument for option '-size': 300+40x168+40 @ convert.c/ConvertImageCommand/2347.

Since the only other way for us to know the size of an image is to run an assembly, process the response data, and then run another assembly using the meta width and height from the first, this seems like a great way to allow things to be chained together a little more dynamically.

Alternatively, relative height and width values would also work pretty well:

"steps": {
   "add-20px-border": {
      "robot": "/image/resize",
      "resize_strategy": "pad",
      "zoom": false,
      "width": "+40",
      "height": "+40"
   }
}

Hey Brian,

interesting. We’ll explore this.

Best,
Tim