How I Made Sharp 950x Faster (And Why It Matters After Bun Joined Anthropic)
Source: Dev.to
The Problem with Sharp
Sharp is a battle‑tested image library used in thousands of production apps, but it has several limitations that become painful in modern serverless and high‑concurrency environments:
- No native HEIC support out of the box
- Requires building libvips from source
- Custom Docker layers needed for AWS Lambda
- Complex CI/CD pipelines
- Slow metadata extraction (decodes the entire image)
- Heavy under concurrent load, not optimized for serverless
These issues caused slow processing, expensive servers, and poor user experience in an image‑heavy application.
Introducing bun-image-turbo
A Rust‑powered image processing library built for Bun and Node.js from day one.
- 100 % open source, MIT licensed, free forever
- Install with a single command:
npm install bun-image-turbo
- No custom builds or compilation required
- Native HEIC support included
Benchmarks
| Operation | Sharp | bun-image-turbo | Improvement |
|---|---|---|---|
| WebP Metadata | 3.4 ms | 0.004 ms | 950× faster |
| JPEG Metadata | 0.1 ms | 0.003 ms | 38× faster |
| PNG Metadata | 0.08 ms | 0.002 ms | 40× faster |
| 50 Concurrent Ops | 160 ms | 62 ms | 2.6× faster |
| Transform Pipeline | 19.1 ms | 12.2 ms | 1.6× faster |
| HEIC Support | ❌ (custom build) | ✅ Native | — |
Metadata extraction
Sharp decodes the whole image to read dimensions:
10 MB image → decode 10 MB → extract width/height → done (3.4 ms)
bun-image-turbo reads only the header bytes:
10 MB image → read ~100 bytes header → extract width/height → done (0.004 ms)
Downscaling strategy
For large downscales, bun-image-turbo uses progressive halving with the optimal filter at each step:
| Scale factor | Algorithm |
|---|---|
| > 4× downscale | Box (fast, good averaging) |
| 2–4× downscale | Bilinear (fast, acceptable quality) |
- GitHub:
- npm:
What You Get
| Feature | Benefit |
|---|---|
| Metadata extraction | 950× faster |
| Concurrent operations | 2.6× faster |
| Transform pipelines | 1.6× faster |
| HEIC support | Native, no custom builds |
| Blurhash | Built‑in |
| Price | Free forever |
Getting Started
npm install bun-image-turbo
For questions, drop a comment in the repository issues. If you find this useful, consider starring the repo ⭐.