Skip to main content

Overview

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

Adding build configurations

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 and rotates an image
  • Adds a watermark to the 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 .