Filters & Effects

Learn how to apply filters and effects to images using BoxLang's image manipulation module

Apply visual effects like blur, sharpen, grayscale, and color adjustments to your images.

Table of Contents

Color Adjustments

Grayscale Conversion

Convert color images to grayscale (black and white):

// Convert to grayscale
ImageNew("colorful.jpg")
    .grayScale()
    .write("grayscale.jpg");

BIF Syntax:

Use Cases:

  • Black and white photography effects

  • Reducing file size

  • Preparing images for printing

  • Artistic effects

Negative/Invert

Invert all colors to create a negative effect:

BIF Syntax:

How it works:

  • Each RGB value is subtracted from 255

  • Red becomes cyan, green becomes magenta, etc.

  • Alpha transparency is preserved

Blur Effects

Gaussian Blur

Apply Gaussian blur filter to soften or smooth images:

BIF Syntax:

Radius Parameter:

  • 1-3 - Subtle blur, slight softening

  • 4-7 - Moderate blur, noticeable effect

  • 8-15 - Heavy blur, significant softening

  • 15+ - Extreme blur, very soft/dreamy

Use Cases:

  • Creating background effects

  • Softening skin in portraits

  • Reducing noise

  • Creating depth of field effects

  • Privacy (blurring faces/text)

Blur Examples

Sharpen Effects

Image Sharpening

Enhance edge definition and detail:

BIF Syntax:

Gain Parameter:

  • 0.5-1.5 - Subtle sharpening, natural look

  • 1.5-3 - Moderate sharpening, enhanced detail

  • 3-5 - Heavy sharpening, very pronounced edges

  • 5+ - Extreme sharpening (may introduce artifacts)

Use Cases:

  • Enhancing photos after resizing

  • Improving focus appearance

  • Compensating for camera blur

  • Preparing images for print

⚠️ Warning: Over-sharpening can create halos and artifacts. Use moderation.

Sharpen Examples

Image Compositing

Overlay Images

Blend one image on top of another with transparency:

BIF Syntax:

Parameters:

  • overlayImage - The image to overlay

  • compositeRule - Blend mode (see below)

  • transparency - 0.0 (transparent) to 1.0 (opaque)

Composite Rules:

  • normal - Standard overlay (default)

  • multiply - Darkens by multiplying colors

  • screen - Lightens by inverting, multiplying, and inverting

  • overlay - Combines multiply and screen

  • darken - Uses darker of two colors

  • lighten - Uses lighter of two colors

Overlay Examples

Paste/Draw Images

Paste one image onto another at specific coordinates:

BIF Syntax:

Combining Effects

Sequential Effects

Chain multiple effects for complex results:

Photo Enhancement Pipeline

Vintage Effect

Soft Focus Effect

Dramatic Black & White

Complete Effect Examples

Privacy Blur Regions

Multi-Layer Composite

Tilt-Shift Effect

Before and After Comparison

Effect Intensity Guidelines

Blur Intensity

Radius
Effect
Use Case

1-2

Very subtle

Noise reduction

3-5

Noticeable

Soft focus, skin smoothing

6-10

Moderate

Background blur

11-20

Heavy

Privacy, artistic effects

20+

Extreme

Completely obscured

Sharpen Intensity

Gain
Effect
Use Case

0.5-1.0

Subtle

General enhancement

1.0-2.0

Moderate

After resizing

2.0-3.0

Strong

Product photos

3.0-5.0

Heavy

Technical images

5.0+

Extreme

May cause artifacts

Performance Tips

  1. Apply blur last - Blurring is computationally expensive

  2. Resize before effects - Smaller images process faster

  3. Combine operations - Use method chaining to reduce intermediate files

  4. Cache processed versions - Don't reprocess on every request

Next Steps

Last updated

Was this helpful?