Last updated: May 29, 2024

<span aria-hidden="true" id="introducing-the-scriptrun-robot-for-code-evaluation"></span>

# Introducing the /script/run Robot for code evaluation

![Joseph Grabski](/assets/images/teammates/joseph2.png?dpl=dpl_3fBRD5jmFtSDABLXGJJyXU1nVXf8)

**Joseph Grabski**

Content Lead · Rochester, United Kingdom · Show bio

[](https://x.com/joe%5Fgrabski)[](https://github.com/Missing-Tech)

We're happy to have the chance to reveal the shiny new [/script/run](/docs/robots/script-run.md) Robot to you. Thanks to the introduction of code evaluation into the Transloadit toolkit that it brings, your Assemblies now have the expansive capabilities of modern JavaScript!

By including custom code within your parameters, using `${...}`, we'll automatically execute the code and return the result value to be used within your Assembly.

Simple variable lookups such as `${file.meta.width}` are classified to not require theRobot's JavaScript interpreter, and remain free. More complex expansions will require us to invoke the [/script/run](/docs/robots/script-run.md) Robot under the hood, with there being a single [charge](/docs/robots/script-run.md) for each Dynamic Evaluation.

![/script/run Robot](/_next/static/immutable/media/opengraph-image.0a5bp31uo2829.png)

<span aria-hidden="true" id="creating-a-template"></span>

## Creating a Template

As a small demonstration, let's create a Template that resizes an image to fit the[golden ratio⁠](https://en.wikipedia.org/wiki/Golden%5Fratio).

```json
{
  "steps": {
    ":original": {
      "robot": "/upload/handle"
    },
    "golden_ratio_resized": {
      "use": ":original",
      "robot": "/image/resize",
      "width": "${file.meta.height * (1 + Math.sqrt(5))/2}",
      "height": "${file.meta.height}",
      "resize_strategy": "fillcrop",
      "result": true,
      "imagemagick_stack": "{{stacks.imagemagick.recommended_version}}"
    },
    "exported": {
      "robot": "/s3/store",
      "use": "golden_ratio_resized",
      "result": true,
      "credentials": "s3defaultBucket",
      "path": "golden_ratio/${file.name}"
    }
  }
}

```

Looking at the JSON above, you'll notice that the `golden_ratio_resized` Step contains the [/script/run](/docs/robots/script-run.md) functionality contained within our[/image/resize](/docs/robots/image-resize.md) Robot. This keeps our JSON as efficient as possible.

To resize our image to the golden ratio, we leave the `height` the same as the original height of the file, then change the `width` according to the golden ratio based on that original height. We also use the `fillcrop` resize strategy so the image can expand to fill the frame.

<span aria-hidden="true" id="testing"></span>

## Testing

To ensure that everything works as expected, let's upload a picture of a friendly-looking cat and check out the new aspect ratio.

Just like that, we're automatically altering our images with no need to run prerequisite calculations on our backend.

<span aria-hidden="true" id="finishing-up"></span>

## Finishing up

And that brings us to the end of this demonstration. We look forward to seeing the ingenious ways that you'll find to utilize the [/script/run](/docs/robots/script-run.md) Robot in your projects. We're also interested in your feedback on this latest addition to ourRobot family, and do let us know if there are any other features you'd like to see included in the future!

[#script-run-robot](/blog/tags/script-run-robot.md)[#code-evaluation-service](/blog/tags/code-evaluation-service.md)[#walkthrough](/blog/tags/walkthrough.md)[#image-resize-robot](/blog/tags/image-resize-robot.md)

### 👩‍💻 Join 20k+ developers

Sign up for our [monthly newsletter](/newsletters.md) to receive direct links to 3 exclusive tech — and 2 product updates. No less, no more.

Your email:

Get access

## File uploading and encoding. Made simple.

Transloadit streamlines file handling for developers, trusted by brands like Coursera and The New York Times. We’re known for a reliable API, top-notch support, and a strong commitment to open source, with projects like [Uppy⁠](https://uppy.io) and [Tus⁠](https://tus.io) setting standards in file processing.

[Sign up](/c/)[Book a Demo](https://survey.typeform.com/to/kRg47Xi5)

No credit card needed · 5 GB included in the free plan

Cancel anytime
