Aviary
Packages

@dudousxd/nestjs-media-image-sharp

The default ImageProcessor, backed by sharp.

The default image engine for conversions, implementing the ImageProcessor SPI on top of sharp.

import { SharpImageProcessor } from '@dudousxd/nestjs-media-image-sharp';

MediaModule.forRoot({
  // …
  imageProcessor: new SharpImageProcessor(),
  collections: [{ name: 'gallery', conversions: [{ name: 'thumb', width: 200 }] }],
});

What it supports

Each ConversionPreset maps to a sharp pipeline:

  • resize via width / height with fit (cover · contain · fill · inside · outside)
  • format conversion to webp (default) · jpeg · png · avif
  • quality control

It returns the encoded buffer plus the output format and contentType, which the library writes next to the original and records on the MediaRecord.

Swapping engines

The processor is just an SPI — ImageProcessor.convert(input, preset). Provide your own implementation (ImageMagick, a remote transform service, a GPU pipeline) to MediaModule's imageProcessor option; nothing else changes. See Conversions → Pluggable engine.

Peer dependencies

sharp (^0.33) and @dudousxd/nestjs-media-core. sharp ships prebuilt binaries for common platforms; for unusual targets see sharp's install docs.

On this page