HeadlinesBriefing favicon HeadlinesBriefing.com

Bun.Image: Zero-Dependency Image Processing Pipeline for JavaScript

Hacker News •
×

Bun introduced Bun.Image, a new image processing pipeline that handles JPEG, PNG, WebP, HEIC, and AVIF formats without any npm dependencies. The API chains transforms like resize and rotate, then outputs to various formats. Built on libjpeg-turbo and SIMD kernels, it processes images off the JavaScript thread for better performance.

The design mirrors Sharp's familiar pattern: construct from input, chain operations, then await a terminal method. Bun.Image accepts file paths, buffers, or blobs from sources like Bun.file() and Bun.s3(). Format detection happens automatically from byte inspection rather than file extensions.

Developers can resize with multiple fit options, apply filters like lanczos3 or mitchell, and modulate brightness and saturation. Output formats include JPEG with quality settings, PNG with palette options, WebP, HEIC, and AVIF. The pipeline integrates with Bun.serve for server-side processing.

Bun.Image eliminates the need for external dependencies like Sharp while delivering comparable functionality. The off-thread processing and SIMD acceleration make it particularly attractive for server-side image manipulation workflows.