Filters

Node Browser

Visual adjustments and effects: blur, sharpen, and colour operations.

blur

.blur(sigma?: number): Pipeline
.blur(sigma?: number): Pipeline

Gaussian blur. sigma controls the blur radius — higher values produce stronger blur.

ParamTypeDefaultDescription
sigmanumbermild blurStandard deviation of the Gaussian kernel (0.3–1000)
// Mild blur (default)
await img('photo.jpg').blur().toBuffer()

// Strong blur
await img('photo.jpg').blur(10).toBuffer()

// Background blur effect
await img('photo.jpg').blur(20).toBuffer()
// Mild blur (default)
await img('photo.jpg').blur().toBuffer()

// Strong blur
await img('photo.jpg').blur(10).toBuffer()

// Background blur effect
await img('photo.jpg').blur(20).toBuffer()

sharpen

.sharpen(options?: SharpenOptions): Pipeline
.sharpen(options?: SharpenOptions): Pipeline

Unsharp mask sharpening. Recovers detail after resizing.

OptionTypeDefaultDescription
sigmanumber1Gaussian sigma of the sharpening mask
m1number1Flat area sharpening strength
m2number2Jagged area sharpening strength
// Default sharpening — good for post-resize cleanup
await img('photo.jpg').resize(800).sharpen().toBuffer()

// Custom parameters
await img('photo.jpg').sharpen({ sigma: 1.5, m1: 1, m2: 2 }).toBuffer()
// Default sharpening — good for post-resize cleanup
await img('photo.jpg').resize(800).sharpen().toBuffer()

// Custom parameters
await img('photo.jpg').sharpen({ sigma: 1.5, m1: 1, m2: 2 }).toBuffer()

median

.median(size?: number): Pipeline
.median(size?: number): Pipeline

Median filter for noise reduction. Preserves edges better than Gaussian blur.

ParamTypeDefaultDescription
sizenumber3Square kernel size in pixels
// Default — 3x3 kernel
await img('photo.jpg').median().toBuffer()

// Stronger noise reduction
await img('photo.jpg').median(5).toBuffer()
// Default — 3x3 kernel
await img('photo.jpg').median().toBuffer()

// Stronger noise reduction
await img('photo.jpg').median(5).toBuffer()

grayscale

.grayscale(): Pipeline
.grayscale(): Pipeline

Convert to greyscale using luminance weights.

await img('photo.jpg').grayscale().toBuffer()

// Greyscale JPEG
await img('photo.jpg').grayscale().jpeg({ quality: 85 }).toBuffer()
await img('photo.jpg').grayscale().toBuffer()

// Greyscale JPEG
await img('photo.jpg').grayscale().jpeg({ quality: 85 }).toBuffer()

tint

.tint(colour: string | { r: number, g: number, b: number }): Pipeline
.tint(colour: string | { r: number, g: number, b: number }): Pipeline

Merge the image with a solid colour. The image luminance is preserved.

// Hex colour
await img('photo.jpg').tint('#ff6600').toBuffer()

// RGB object
await img('photo.jpg').tint({ r: 255, g: 102, b: 0 }).toBuffer()
// Hex colour
await img('photo.jpg').tint('#ff6600').toBuffer()

// RGB object
await img('photo.jpg').tint({ r: 255, g: 102, b: 0 }).toBuffer()

negate

.negate(): Pipeline
.negate(): Pipeline

Invert pixel values (photographic negative).

await img('photo.jpg').negate().toBuffer()
await img('photo.jpg').negate().toBuffer()

brightness

.brightness(factor: number): Pipeline
.brightness(factor: number): Pipeline

Multiply brightness. 1.0 is unchanged.

ValueEffect
< 1.0Darker
1.0No change
> 1.0Brighter
// 20% brighter
await img('photo.jpg').brightness(1.2).toBuffer()

// 30% darker
await img('photo.jpg').brightness(0.7).toBuffer()
// 20% brighter
await img('photo.jpg').brightness(1.2).toBuffer()

// 30% darker
await img('photo.jpg').brightness(0.7).toBuffer()

contrast

.contrast(factor: number): Pipeline
.contrast(factor: number): Pipeline

Multiply contrast. 1.0 is unchanged.

// Increase contrast
await img('photo.jpg').contrast(1.3).toBuffer()

// Reduce contrast (flatten)
await img('photo.jpg').contrast(0.8).toBuffer()
// Increase contrast
await img('photo.jpg').contrast(1.3).toBuffer()

// Reduce contrast (flatten)
await img('photo.jpg').contrast(0.8).toBuffer()

saturation

.saturation(factor: number): Pipeline
.saturation(factor: number): Pipeline

Multiply colour saturation. 0 produces greyscale, 1.0 is unchanged.

// Vibrant colours
await img('photo.jpg').saturation(1.5).toBuffer()

// Desaturate (muted tones)
await img('photo.jpg').saturation(0.5).toBuffer()

// Full greyscale via saturation
await img('photo.jpg').saturation(0).toBuffer()
// Vibrant colours
await img('photo.jpg').saturation(1.5).toBuffer()

// Desaturate (muted tones)
await img('photo.jpg').saturation(0.5).toBuffer()

// Full greyscale via saturation
await img('photo.jpg').saturation(0).toBuffer()

Combining filters

Filters chain in order, left to right:

await img('photo.jpg')
  .resize(1200)
  .brightness(1.05)
  .contrast(1.1)
  .saturation(1.2)
  .sharpen()
  .webp({ quality: 85 })
  .toBuffer()
await img('photo.jpg')
  .resize(1200)
  .brightness(1.05)
  .contrast(1.1)
  .saturation(1.2)
  .sharpen()
  .webp({ quality: 85 })
  .toBuffer()