bun-image-turbo 1.0.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,7 +12,8 @@ High-performance image processing for Bun and Node.js, built with Rust and napi-
12
12
  ## Features
13
13
 
14
14
  - **Fast** - Built with Rust for maximum performance
15
- - **Modern Formats** - JPEG, PNG, WebP, GIF, BMP support
15
+ - **Modern Formats** - JPEG, PNG, WebP, GIF, BMP, **HEIC/HEIF** support
16
+ - **HEIC Support** - Read iPhone photos and HEIC/HEIF files natively
16
17
  - **Resize** - High-quality resizing with multiple algorithms (Lanczos3, Mitchell, etc.)
17
18
  - **Transform** - Rotate, flip, blur, sharpen, grayscale, brightness, contrast
18
19
  - **Blurhash** - Generate compact image placeholders
@@ -26,55 +27,60 @@ Tested on Apple M1 Pro with Bun 1.3.3 (compared to sharp v0.34.5):
26
27
 
27
28
  ### Performance Summary
28
29
 
30
+ ```text
31
+ ┌──────────────────────────────────────────────────────────────────────────────┐
32
+ │ bun-image-turbo vs sharp Performance │
33
+ ├──────────────────────────────────────────────────────────────────────────────┤
34
+ │ WebP Metadata ████████████████████████████████████ 950x faster │
35
+ │ JPEG Metadata ████████████████████████████████████ 38x faster │
36
+ │ Concurrent (50 ops) ██████████████████████████ 2.6x faster │
37
+ │ Transform Pipeline ████████████████████ 1.6x faster │
38
+ │ Thumbnail Resize ████████████████ 1.2x faster │
39
+ │ HEIC Support ████████████████████ EXCLUSIVE N/A in sharp │
40
+ │ Blurhash Generation ████████████████████ EXCLUSIVE N/A in sharp │
41
+ └──────────────────────────────────────────────────────────────────────────────┘
29
42
  ```
30
- ┌─────────────────────────────────────────────────────────────────────────────┐
31
- │ bun-image-turbo vs sharp Performance │
32
- ├─────────────────────────────────────────────────────────────────────────────┤
33
- │ Metadata Extraction ████████████████████████████████████ 36x faster │
34
- │ Transform Pipeline ████████████████████ 3.4x faster │
35
- │ Concurrent (50 ops) ██████████████████████████ 4.5x faster │
36
- │ JPEG Encode ██████████████ 1.9x faster │
37
- │ Thumbnail Resize ████████████ 1.9x faster │
38
- │ Blurhash Generation ████████████████████ (4,283 ops/sec) N/A in sharp │
39
- └─────────────────────────────────────────────────────────────────────────────┘
40
- ```
41
-
42
- ### Detailed Benchmarks (ops/sec - higher is better)
43
-
44
- | Operation | bun-image-turbo | sharp | Winner |
45
- |-----------|---------------:|------:|:------:|
46
- | **Metadata Extraction** | 350,000 ops/sec | 9,600 ops/sec | **36x faster** |
47
- | **Transform Pipeline** | 454 ops/sec | 134 ops/sec | **3.4x faster** |
48
- | **JPEG Encode** | 553 ops/sec | 287 ops/sec | **1.9x faster** |
49
- | **Thumbnail (200px)** | 386 ops/sec | 201 ops/sec | **1.9x faster** |
50
- | **PNG Encode** | 235 ops/sec | 221 ops/sec | **1.06x faster** |
51
- | **Blurhash** | 4,283 ops/sec | N/A | - |
52
43
 
53
- ### Concurrent Operations (High Load)
54
-
55
- | Concurrency | bun-image-turbo | sharp | Throughput |
56
- |------------:|----------------:|------:|:----------:|
57
- | 50 parallel | 30ms total | 137ms total | **4.5x faster** |
58
- | **Ops/sec** | **1,653 ops/sec** | 364 ops/sec | - |
59
-
60
- ### Real-World File Tests
44
+ ### Detailed Benchmarks
61
45
 
62
46
  | Operation | bun-image-turbo | sharp | Speedup |
63
47
  |-----------|---------------:|------:|:-------:|
64
- | 1MB JPEG Metadata | 0.003ms | 0.10ms | **36x faster** |
65
- | 1MB JPEG Transform | 25.3ms | 30.5ms | **1.2x faster** |
66
- | 10MB JPEG Metadata | 0.003ms | 0.10ms | **37x faster** |
48
+ | **10MB WebP Metadata** | 0.004ms | 3.4ms | **950x faster** |
49
+ | **10MB JPEG Metadata** | 0.003ms | 0.1ms | **38x faster** |
50
+ | **1MB JPEG Metadata** | 0.003ms | 0.1ms | **30x faster** |
51
+ | **50 Concurrent Ops** | 62ms | 160ms | **2.6x faster** |
52
+ | **Transform Pipeline** | 12.2ms | 19.1ms | **1.6x faster** |
53
+ | **1MB JPEG → 800px** | 12.6ms | 20.3ms | **1.6x faster** |
54
+ | **1MB JPEG → WebP** | 36.4ms | 46.1ms | **1.3x faster** |
55
+ | **Thumbnail (200px)** | 8.8ms | 10.7ms | **1.2x faster** |
56
+
57
+ ### HEIC/HEIF Support (Exclusive)
58
+
59
+ bun-image-turbo is the **only** high-performance image library with native HEIC support:
60
+
61
+ | Operation | Time | Notes |
62
+ |-----------|-----:|:------|
63
+ | **HEIC Metadata** | 0.1ms | Instant metadata extraction |
64
+ | **HEIC → JPEG** | 169ms | Full quality conversion |
65
+ | **HEIC → 800px JPEG** | 138ms | Optimized shrink-on-decode |
66
+ | **HEIC → 200px thumbnail** | 137ms | Fast thumbnail generation |
67
+ | **HEIC → WebP** | 798ms | Modern format conversion |
68
+ | **HEIC Blurhash** | 301ms | Placeholder generation |
69
+
70
+ > sharp does **NOT** support HEIC/HEIF files!
67
71
 
68
72
  ### Key Strengths
69
73
 
70
- - **36x faster** metadata extraction (header-only parsing)
71
- - **4.5x faster** under concurrent load (server workloads)
72
- - **3.4x faster** transform pipelines (resize + rotate + grayscale)
73
- - **1.9x faster** JPEG encoding with TurboJPEG (libjpeg-turbo SIMD)
74
- - Built-in **Blurhash** generation (4,283 ops/sec)
74
+ - **950x faster** WebP metadata extraction
75
+ - **38x faster** JPEG metadata (header-only parsing)
76
+ - **2.6x faster** under concurrent load (server workloads)
77
+ - **1.6x faster** transform pipelines (resize + rotate + grayscale)
78
+ - **Native HEIC/HEIF support** - Read iPhone photos directly
79
+ - **Shrink-on-decode** optimization for JPEG and HEIC
80
+ - Built-in **Blurhash** generation
75
81
  - Zero-copy buffer handling with Rust
76
82
 
77
- > Run benchmarks yourself: `bun run bench`
83
+ > Run benchmarks yourself: `bun run benchmarks/final_comparison.ts`
78
84
 
79
85
  ## Installation
80
86
 
@@ -121,6 +127,11 @@ const result = await transform(buffer, {
121
127
 
122
128
  // Save result
123
129
  await Bun.write('output.webp', result);
130
+
131
+ // Convert HEIC (iPhone photo) to JPEG
132
+ const heicInput = await Bun.file('photo.heic').arrayBuffer();
133
+ const jpeg = await toJpeg(Buffer.from(heicInput), { quality: 90 });
134
+ await Bun.write('photo.jpg', jpeg);
124
135
  ```
125
136
 
126
137
  ## API Reference
@@ -274,15 +285,17 @@ console.log(version()); // "1.0.0"
274
285
 
275
286
  ## Supported Formats
276
287
 
277
- | Format | Read | Write |
278
- |--------|------|-------|
279
- | JPEG | Yes | Yes |
280
- | PNG | Yes | Yes |
281
- | WebP | Yes | Yes |
282
- | GIF | Yes | Yes |
283
- | BMP | Yes | Yes |
284
- | ICO | Yes | No |
285
- | TIFF | Yes | No |
288
+ | Format | Read | Write | Notes |
289
+ |--------|------|-------|-------|
290
+ | JPEG | Yes | Yes | TurboJPEG with SIMD |
291
+ | PNG | Yes | Yes | Adaptive compression |
292
+ | WebP | Yes | Yes | Lossy & lossless |
293
+ | HEIC/HEIF | Yes | No | iPhone photos, via libheif |
294
+ | AVIF | Yes | No | Via libheif |
295
+ | GIF | Yes | Yes | Animated support |
296
+ | BMP | Yes | Yes | - |
297
+ | ICO | Yes | No | Multi-size icons |
298
+ | TIFF | Yes | No | Multi-page support |
286
299
 
287
300
  ## Supported Platforms
288
301
 
@@ -335,5 +348,6 @@ Aissam Irhir ([@nexus-aissam](https://github.com/nexus-aissam))
335
348
  - [image](https://crates.io/crates/image) - Rust image processing library
336
349
  - [fast_image_resize](https://crates.io/crates/fast_image_resize) - Fast image resizing
337
350
  - [webp](https://crates.io/crates/webp) - WebP encoding/decoding
351
+ - [libheif-rs](https://crates.io/crates/libheif-rs) - HEIC/HEIF decoding via libheif
338
352
  - [blurhash](https://crates.io/crates/blurhash) - Blurhash generation
339
353
  - [napi-rs](https://napi.rs/) - Rust bindings for Node.js
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@
2
2
  * bun-image-turbo Types
3
3
  */
4
4
  /** Supported image formats */
5
- type ImageFormat = 'jpeg' | 'png' | 'webp' | 'gif' | 'bmp' | 'ico' | 'tiff' | 'avif';
5
+ type ImageFormat = 'jpeg' | 'png' | 'webp' | 'gif' | 'bmp' | 'ico' | 'tiff' | 'heic' | 'avif';
6
6
  /** Resize filter/algorithm */
7
7
  type ResizeFilter = 'nearest' | 'bilinear' | 'catmullRom' | 'mitchell' | 'lanczos3';
8
8
  /** Image fit mode for resize */
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * bun-image-turbo Types
3
3
  */
4
4
  /** Supported image formats */
5
- type ImageFormat = 'jpeg' | 'png' | 'webp' | 'gif' | 'bmp' | 'ico' | 'tiff' | 'avif';
5
+ type ImageFormat = 'jpeg' | 'png' | 'webp' | 'gif' | 'bmp' | 'ico' | 'tiff' | 'heic' | 'avif';
6
6
  /** Resize filter/algorithm */
7
7
  type ResizeFilter = 'nearest' | 'bilinear' | 'catmullRom' | 'mitchell' | 'lanczos3';
8
8
  /** Image fit mode for resize */
package/dist/index.js CHANGED
@@ -127,7 +127,9 @@ function toNapiFormat(format) {
127
127
  gif: "Gif",
128
128
  bmp: "Bmp",
129
129
  ico: "Ico",
130
- tiff: "Tiff"
130
+ tiff: "Tiff",
131
+ heic: "Heic",
132
+ avif: "Avif"
131
133
  };
132
134
  return formatMap[format.toLowerCase()] || format;
133
135
  }
package/dist/index.mjs CHANGED
@@ -94,7 +94,9 @@ function toNapiFormat(format) {
94
94
  gif: "Gif",
95
95
  bmp: "Bmp",
96
96
  ico: "Ico",
97
- tiff: "Tiff"
97
+ tiff: "Tiff",
98
+ heic: "Heic",
99
+ avif: "Avif"
98
100
  };
99
101
  return formatMap[format.toLowerCase()] || format;
100
102
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-image-turbo",
3
- "version": "1.0.5",
4
- "description": "High-performance image processing for Bun and Node.js - resize, convert, compress with WebP, AVIF, PNG, JPEG support",
3
+ "version": "1.2.0",
4
+ "description": "High-performance image processing for Bun and Node.js - resize, convert, compress with HEIC, WebP, AVIF, PNG, JPEG support",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
@@ -50,12 +50,15 @@
50
50
  "image",
51
51
  "resize",
52
52
  "compress",
53
+ "heic",
54
+ "heif",
53
55
  "webp",
54
56
  "avif",
55
57
  "png",
56
58
  "jpeg",
57
59
  "jpg",
58
60
  "gif",
61
+ "iphone",
59
62
  "thumbnail",
60
63
  "crop",
61
64
  "convert",
@@ -89,12 +92,12 @@
89
92
  "typescript": "^5.9.0"
90
93
  },
91
94
  "optionalDependencies": {
92
- "bun-image-turbo-darwin-arm64": "1.0.5",
93
- "bun-image-turbo-darwin-x64": "1.0.5",
94
- "bun-image-turbo-linux-arm64-gnu": "1.0.5",
95
- "bun-image-turbo-linux-x64-gnu": "1.0.5",
96
- "bun-image-turbo-linux-x64-musl": "1.0.5",
97
- "bun-image-turbo-win32-arm64-msvc": "1.0.5",
98
- "bun-image-turbo-win32-x64-msvc": "1.0.5"
95
+ "bun-image-turbo-darwin-arm64": "1.2.0",
96
+ "bun-image-turbo-darwin-x64": "1.2.0",
97
+ "bun-image-turbo-linux-arm64-gnu": "1.2.0",
98
+ "bun-image-turbo-linux-x64-gnu": "1.2.0",
99
+ "bun-image-turbo-linux-x64-musl": "1.2.0",
100
+ "bun-image-turbo-win32-arm64-msvc": "1.2.0",
101
+ "bun-image-turbo-win32-x64-msvc": "1.2.0"
99
102
  }
100
103
  }