Skip to content

imgkitHigh-Performance Image Processing

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

imgkit

Why imgkit? ​

Built from the ground up for maximum performance, imgkit 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:

OperationimgkitsharpSpeedup
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

WebP Resize ​

Source SizeTargetimgkitsharpSpeedup
800x600200px3.1ms4.3ms1.40x
1600x1200200px6.4ms8.0ms1.24x
2000x1500200px8.6ms10.1ms1.18x
3000x2000200px14.7ms16.1ms1.10x
4000x3000400px32.4ms33.1ms1.02x

Shrink-on-load optimization using libwebp's native scaling - faster than sharp across ALL sizes!

HEIC Support (Exclusive Feature) ​

imgkit 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 imgkit
typescript
import { metadata, resize, crop, transform, thumbhash, toTensor } from 'imgkit';

// 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}`);

// Crop to aspect ratio (zero-copy, ultra-fast)
const squared = await crop(buffer, { aspectRatio: "1:1" });

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

// Full transform pipeline with crop + resize
const result = await transform(buffer, {
  crop: { aspectRatio: "16:9" },
  resize: { width: 1280 },
  sharpen: 5,
  output: { format: 'WebP', webp: { quality: 85 } }
});

// Generate thumbhash placeholder (better than blurhash)
const { dataUrl } = await thumbhash(buffer);
// Use directly: <img src={dataUrl} />

// ML tensor conversion (first JS package with native SIMD!)
const tensor = await toTensor(buffer, {
  width: 224, height: 224,
  normalization: 'Imagenet',
  layout: 'Chw', batch: true
});
// Shape: [1, 3, 224, 224] - Ready for PyTorch/ONNX!

Supported Formats ​

FormatReadWriteNotes
JPEG✅✅TurboJPEG with SIMD
PNG✅✅Adaptive compression
WebP✅✅Lossy & lossless
HEIC/HEIF✅❌macOS ARM64 only
AVIF✅❌Via libheif
GIF✅✅Animated support
BMP✅✅Full 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.