Skip to content

bun-image-turboHigh-Performance Image Processing

Native Rust library for Bun and Node.js. Up to 950x faster than alternatives.

bun-image-turbo

Why bun-image-turbo?

Built from the ground up for maximum performance, bun-image-turbo uses native Rust with carefully optimized codepaths for each operation.

Architecture Highlights

ComponentTechnologyBenefit
JPEG CodecTurboJPEG (libjpeg-turbo)SIMD acceleration (SSE2/AVX2/NEON)
Resize Enginefast_image_resize + RayonMulti-threaded with adaptive algorithms
WebP Codeclibwebp bindingsGoogle's optimized encoder/decoder
HEIC Decoderlibheif-rsNative Apple format support
Node Bindingsnapi-rsZero-copy buffer handling

Performance Benchmarks

Tested on Apple M1 Pro with Bun 1.3.3:

Operationbun-image-turbosharpSpeedup
WebP Metadata0.004ms3.4ms950x
JPEG Metadata0.003ms0.1ms38x
50 Concurrent Ops62ms160ms2.6x
Transform Pipeline12.2ms19.1ms1.6x
1MB JPEG → 800px12.6ms20.3ms1.6x
Thumbnail (200px)8.8ms10.7ms1.2x

HEIC Support (Exclusive Feature)

bun-image-turbo is the only high-performance image library with native HEIC support:

OperationTimeNotes
HEIC Metadata0.1msHeader-only parsing
HEIC → JPEG169msFull quality conversion
HEIC → 800px138msShrink-on-decode optimization
HEIC → Thumbnail137msFast 200px generation

Note: sharp does NOT support HEIC/HEIF files!

Quick Start

bash
bun add bun-image-turbo
typescript
import { metadata, resize, transform, blurhash } from 'bun-image-turbo';

// Read image
const buffer = Buffer.from(await Bun.file('photo.jpg').arrayBuffer());

// Get metadata (header-only, ultra-fast)
const info = await metadata(buffer);
console.log(`${info.width}x${info.height} ${info.format}`);

// Resize with shrink-on-decode optimization
const thumbnail = await resize(buffer, { width: 200 });

// Full transform pipeline
const result = await transform(buffer, {
  resize: { width: 800, height: 600, fit: 'cover' },
  rotate: 90,
  sharpen: 10,
  output: { format: 'webp', webp: { quality: 85 } }
});

// Generate blurhash placeholder
const { hash } = await blurhash(buffer, 4, 3);

Supported Formats

FormatReadWriteNotes
JPEGTurboJPEG with SIMD
PNGAdaptive compression
WebPLossy & lossless
HEIC/HEIFmacOS ARM64 only
AVIFVia libheif
GIFAnimated support
BMPFull support

Platform Support

Prebuilt binaries are available for all major platforms:

PlatformArchitectureSupportedHEIC
macOSARM64 (M1/M2/M3/M4/M5)
macOSx64 (Intel)
Linuxx64 (glibc)
Linuxx64 (musl/Alpine)
LinuxARM64 (glibc)
Windowsx64
WindowsARM64

Note: HEIC/HEIF decoding is only available on macOS ARM64. All other image formats (JPEG, PNG, WebP, GIF, BMP, TIFF) work on all platforms.