nostrbasedocs
Start building
API reference
.md

Read the image processing guide. Signatures below come from the published SDK declarations. Access SDK services through db; use their constructors only when integrating at a lower level.

ImageFormat

type ImageFormat = "png" | "jpeg" | "webp";

ImageTransformOptions

interface ImageTransformOptions {
  width?: number;
  height?: number;
  /** Default: cover. With one dimension, keep the aspect ratio. */
  resize?: "cover" | "contain" | "fill" | "inside";
  format?: ImageFormat;
  /** Encoder quality from 1 to 100; PNG is lossless. */
  quality?: number;
  /** Clockwise degrees, applied before resizing. */
  rotate?: 0 | 90 | 180 | 270;
  flip?: boolean;
  flop?: boolean;
  /** Crop after orientation/rotation and flips, before resizing. */
  crop?: {
    left: number;
    top: number;
    width: number;
    height: number;
  };
  withoutEnlargement?: boolean;
  /** Contain padding and JPEG transparency fill. Default: transparent. */
  background?: string;
}

ImageProcessingOptions

interface ImageProcessingOptions extends ImageTransformOptions {
  signal?: AbortSignal;
}

ImageProcessor

interface ImageProcessor {
  process(
    blob: Blob,
    options: ImageTransformOptions,
    signal?: AbortSignal,
  ): Promise<Blob>;
}

CanvasImageProcessor

/** Built-in local processor. EXIF orientation is decoded before explicit transforms; metadata is removed. */
declare class CanvasImageProcessor implements ImageProcessor {}

process

process(
  blob: Blob,
  options?: ImageTransformOptions,
  signal?: AbortSignal,
): Promise<Blob>;

Search guides, API methods, and protocols.