# Image processing

Public types and methods for image processing.

[Read the image processing guide](/docs/images/). Signatures below come from the published SDK declarations. Access SDK services through `db`; use their constructors only when integrating at a lower level.

## ImageFormat


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

## ImageTransformOptions


```ts
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


```ts
interface ImageProcessingOptions extends ImageTransformOptions {
  signal?: AbortSignal;
}
```

## ImageProcessor


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

## CanvasImageProcessor


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

### process


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