Image Processing

Resize, crop, convert, and transform images using Sharp from your Spala flows.

Image Processing

The Image Processing addon uses the Sharp library to resize, crop, convert, and transform images in your Spala flows. It runs image operations on the server with high performance, supporting JPEG, PNG, WebP, AVIF, GIF, and TIFF formats.

Installation

1. Enable the Image Processing addon from the Addons panel
2. No setup beyond enabling the addon

No API keys or external services are required — all processing happens locally on the server.

Available Steps

Resize Image

Resizes an image to the specified dimensions.

Convert Format

Converts an image to a different format.

Crop Image

Extracts a region from an image.

Get Image Info

Returns metadata about an image (dimensions, format, file size, color space).

Returns:

{
  width: 1920,
  height: 1080,
  format: "jpeg",
  size: 245760,
  channels: 3,
  space: "srgb"
}

Example: Image Upload with Thumbnails

// POST /api/images/upload

// Step 1: Save File (Local Storage addon)
// path: 'uploads/originals/' + input.filename
// content: input.fileData, encoding: 'base64'
// Step 2: Resize Image (Image Processing addon)
// inputPath: storage + '/uploads/originals/' + input.filename
// outputPath: storage + '/uploads/thumbnails/' + input.filename
// width: 200
// height: 200
// fit: 'cover'
// Step 3: Convert Format (Image Processing addon)
// inputPath: storage + '/uploads/originals/' + input.filename
// outputPath: storage + '/uploads/webp/' + input.filename.replace(/\.[^.]+$/, '.webp')
// format: 'webp'
// quality: 85
// Step 4: Database Query - Save image record
// INSERT INTO images (original_path, thumbnail_path, webp_path, ...)
// Step 5: Response
// { image: vars.imageRecord }

Example: Avatar Processing

// POST /api/users/avatar

// Step 1: Save uploaded file temporarily

// Step 2: Get Image Info (Image Processing addon)
// inputPath: vars.tempPath
// Output → vars.info
// Step 3: Condition - Validate dimensions
// If vars.info.width < 100 || vars.info.height < 100
//   Respond with 400: "Image must be at least 100x100 pixels"
// Step 4: Resize Image (Image Processing addon)
// inputPath: vars.tempPath
// outputPath: storage + '/avatars/' + vars.auth.userId + '.webp'
// width: 256, height: 256, fit: 'cover'
// Step 5: Convert Format
// format: 'webp', quality: 90

Sharp processes images in a streaming pipeline, which is memory-efficient even for large images. It uses the libvips library under the hood, which is significantly faster than ImageMagick or GraphicsMagick.

Image processing is CPU-intensive. For high-volume image processing, consider running these operations in background tasks to avoid blocking your API endpoints.

Path to the source image file.
Path where the resized image will be saved.
Target width in pixels. Omit to auto-calculate from height.
Target height in pixels. Omit to auto-calculate from width.
'cover' (crop to fill), 'contain' (fit within), 'fill' (stretch), 'inside', or 'outside'.
Path to the source image file.
Path for the converted image.
'jpeg', 'png', 'webp', 'avif', 'gif', or 'tiff'.
Output quality for lossy formats, 1-100 (default: 80).
Path to the source image.
Path for the cropped image.
Left offset in pixels.
Top offset in pixels.
Width of the crop region.
Height of the crop region.
Path to the image file.
Addons Overview
/addons
Browse available addons
Installing Addons
/addons/installing
Enable and configure addons in your project