Documentation

Image Processing

@shaw/image-processing — the sharp-based engine behind Shaw Image Studio and the asset pipeline.

Capabilities

  • Formats: WebP, AVIF, JPEG, PNG with per-format quality handling.
  • Quality presets: max-compression, balanced, max-quality — or an explicit 1–100 value.
  • Resizing: width/height targets or percentage scale, aspect-ratio safe, never upscaling by default.
  • Watermarks: text or image overlays with nine positions, opacity, size, and padding controls.
  • Naming: prefixes, suffixes, casing rules, and zero-padded sequential numbering for batches.
  • Batch output: ZIP archiving (fflate) and metadata stripping for web delivery.

API surface

Main entry points
processImage(input, settings)   // one image → optimized output
processImages(inputs, settings) // batch processing
WEB_OPTIMIZED_SETTINGS          // the one-click "Optimize for Web" preset
applyWatermark(...)             // text/image overlay composition
buildOutputFilename(...)        // naming rules
buildZip(...)                   // batch archive
validateImageInput(...)         // format/size caps

Where it runs

Shaw Image Studio calls the engine server-side per file from a Next.js API route; the asset pipeline calls the same functions from plain Node with the identical Optimize-for-Web preset, so website assets match what the public tool produces.