Skip to main content

Overview

This task processes and watermarks an image using the Sharp library, and then uploads it to R2 storage.

Prerequisites

Adding the build configuration

To use this example, you’ll first need to add these build settings to your trigger.config.ts file:
trigger.config.ts
Any packages that install or build a native binary should be added to external, as native binaries cannot be bundled.

Key features

  • Resizes a JPEG image to 800x800 pixels
  • Adds a watermark to the image, positioned in the bottom-right corner, using a PNG image
  • Uploads the processed image to R2 storage

Task code

trigger/sharp-image-processing.ts

Testing your task

To test this task in the dashboard, you can use the following payload:

Local development

To test this example task locally, be sure to install any packages from the build extensions you added to your trigger.config.ts file to your local machine. In this case, you need to install .