bun-image-turbo 1.0.5 → 1.2.2

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
@@ -1,319 +1,323 @@
1
- # bun-image-turbo
2
-
3
- High-performance image processing for Bun and Node.js, built with Rust and napi-rs.
4
-
5
- [![npm version](https://badge.fury.io/js/bun-image-turbo.svg)](https://www.npmjs.com/package/bun-image-turbo)
6
- [![Build & Publish](https://github.com/nexus-aissam/bun-image-turbo/actions/workflows/build.yml/badge.svg)](https://github.com/nexus-aissam/bun-image-turbo/actions/workflows/build.yml)
7
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)
9
- [![Node.js](https://img.shields.io/badge/Node.js-18+-green.svg)](https://nodejs.org/)
10
- [![Bun](https://img.shields.io/badge/Bun-1.0+-orange.svg)](https://bun.sh/)
11
-
12
- ## Features
13
-
14
- - **Fast** - Built with Rust for maximum performance
15
- - **Modern Formats** - JPEG, PNG, WebP, GIF, BMP support
16
- - **Resize** - High-quality resizing with multiple algorithms (Lanczos3, Mitchell, etc.)
17
- - **Transform** - Rotate, flip, blur, sharpen, grayscale, brightness, contrast
18
- - **Blurhash** - Generate compact image placeholders
19
- - **Async & Sync** - Both async and sync APIs available
20
- - **TypeScript** - Full TypeScript support with strict types
21
- - **Cross-platform** - macOS, Linux, Windows support
22
-
23
- ## Benchmarks
24
-
25
- Tested on Apple M1 Pro with Bun 1.3.3 (compared to sharp v0.34.5):
26
-
27
- ### Performance Summary
28
-
29
- ```
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
-
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
61
-
62
- | Operation | bun-image-turbo | sharp | Speedup |
63
- |-----------|---------------:|------:|:-------:|
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** |
67
-
68
- ### Key Strengths
69
-
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)
75
- - Zero-copy buffer handling with Rust
76
-
77
- > Run benchmarks yourself: `bun run bench`
1
+ <h1 align="center">
2
+ ⚡ bun-image-turbo
3
+ </h1>
4
+
5
+ <p align="center">
6
+ <strong>High-performance image processing for Bun and Node.js</strong><br>
7
+ Built with Rust and napi-rs for maximum speed
8
+ </p>
9
+
10
+ <p align="center">
11
+ <a href="https://www.npmjs.com/package/bun-image-turbo"><img src="https://badge.fury.io/js/bun-image-turbo.svg" alt="npm version"></a>
12
+ <a href="https://github.com/nexus-aissam/bun-image-turbo/actions/workflows/build.yml"><img src="https://github.com/nexus-aissam/bun-image-turbo/actions/workflows/build.yml/badge.svg" alt="Build & Publish"></a>
13
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
14
+ <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5.0+-blue.svg" alt="TypeScript"></a>
15
+ <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/Node.js-18+-green.svg" alt="Node.js"></a>
16
+ <a href="https://bun.sh/"><img src="https://img.shields.io/badge/Bun-1.0+-orange.svg" alt="Bun"></a>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <a href="https://nexus-aissam.github.io/bun-image-turbo/"><img src="https://img.shields.io/badge/📖_Documentation-Visit_Docs-blue?style=for-the-badge" alt="Documentation"></a>
21
+ <a href="https://nexus-aissam.github.io/bun-image-turbo/api/"><img src="https://img.shields.io/badge/📚_API-Reference-green?style=for-the-badge" alt="API Reference"></a>
22
+ <a href="https://www.npmjs.com/package/bun-image-turbo"><img src="https://img.shields.io/badge/📦_npm-Package-red?style=for-the-badge" alt="npm Package"></a>
23
+ </p>
24
+
25
+ <p align="center">
26
+ <b>Up to 950x faster</b> than alternatives • <b>Native HEIC support</b> • <b>Zero-copy buffers</b> • <b>SIMD-accelerated</b>
27
+ </p>
28
+
29
+ ---
30
+
31
+ ## Why bun-image-turbo?
32
+
33
+ | vs sharp | Speedup | Why |
34
+ |----------|:-------:|-----|
35
+ | WebP Metadata | **950x** | Header-only parsing, no decode |
36
+ | JPEG Metadata | **38x** | Optimized marker extraction |
37
+ | 50 Concurrent Ops | **2.6x** | Rayon thread pool |
38
+ | Transform Pipeline | **1.6x** | Single-pass processing |
39
+ | HEIC Support | **Exclusive** | Only lib with native HEIC |
40
+
41
+ > **bun-image-turbo** is the fastest image processing library for JavaScript. Period.
42
+
43
+ ---
44
+
45
+ ## Quick Links
46
+
47
+ | Resource | Link |
48
+ |----------|------|
49
+ | **Documentation** | [nexus-aissam.github.io/bun-image-turbo](https://nexus-aissam.github.io/bun-image-turbo/) |
50
+ | **API Reference** | [Full API Docs](https://nexus-aissam.github.io/bun-image-turbo/api/) |
51
+ | **Examples** | [Code Examples](https://nexus-aissam.github.io/bun-image-turbo/examples/) |
52
+ | **Getting Started** | [Installation Guide](https://nexus-aissam.github.io/bun-image-turbo/guide/) |
53
+ | **Architecture** | [Technical Deep Dive](https://nexus-aissam.github.io/bun-image-turbo/guide/architecture) |
54
+ | **Performance** | [Benchmarks & Optimization](https://nexus-aissam.github.io/bun-image-turbo/guide/performance) |
55
+ | **npm Package** | [npmjs.com/package/bun-image-turbo](https://www.npmjs.com/package/bun-image-turbo) |
56
+ | **GitHub** | [nexus-aissam/bun-image-turbo](https://github.com/nexus-aissam/bun-image-turbo) |
57
+ | **Changelog** | [Release Notes](https://nexus-aissam.github.io/bun-image-turbo/changelog) |
58
+
59
+ ---
78
60
 
79
61
  ## Installation
80
62
 
81
63
  ```bash
82
- # Using Bun (recommended)
64
+ # Bun (recommended)
83
65
  bun add bun-image-turbo
84
66
 
85
- # Using npm
67
+ # npm
86
68
  npm install bun-image-turbo
87
69
 
88
- # Using yarn
70
+ # yarn
89
71
  yarn add bun-image-turbo
90
72
 
91
- # Using pnpm
73
+ # pnpm
92
74
  pnpm add bun-image-turbo
93
75
  ```
94
76
 
77
+ Prebuilt binaries are available for **all major platforms** - no compilation needed.
78
+
79
+ ---
80
+
95
81
  ## Quick Start
96
82
 
97
83
  ```typescript
98
- import { resize, toWebp, metadata, transform } from 'bun-image-turbo';
84
+ import { metadata, resize, transform, toWebp, blurhash } from 'bun-image-turbo';
99
85
 
100
86
  // Read image
101
- const input = await Bun.file('input.jpg').arrayBuffer();
102
- const buffer = Buffer.from(input);
87
+ const buffer = Buffer.from(await Bun.file('photo.jpg').arrayBuffer());
103
88
 
104
- // Get metadata
89
+ // Get metadata (ultra-fast, header-only)
105
90
  const info = await metadata(buffer);
106
91
  console.log(`${info.width}x${info.height} ${info.format}`);
107
92
 
108
- // Resize image
109
- const resized = await resize(buffer, { width: 800 });
93
+ // Resize with shrink-on-decode optimization
94
+ const thumbnail = await resize(buffer, { width: 200 });
110
95
 
111
- // Convert to WebP
96
+ // Convert to WebP (50-80% smaller than JPEG)
112
97
  const webp = await toWebp(buffer, { quality: 85 });
113
98
 
114
- // Apply multiple transformations
99
+ // Full transform pipeline
115
100
  const result = await transform(buffer, {
116
- resize: { width: 400, height: 300 },
101
+ resize: { width: 800, height: 600, fit: 'cover' },
117
102
  rotate: 90,
118
103
  grayscale: true,
119
- output: { format: 'webp', webp: { quality: 80 } }
104
+ sharpen: 10,
105
+ output: { format: 'webp', webp: { quality: 85 } }
120
106
  });
121
107
 
108
+ // Generate blurhash placeholder
109
+ const { hash } = await blurhash(buffer, 4, 3);
110
+
122
111
  // Save result
123
112
  await Bun.write('output.webp', result);
124
113
  ```
125
114
 
126
- ## API Reference
115
+ **[See more examples →](https://nexus-aissam.github.io/bun-image-turbo/examples/)**
127
116
 
128
- ### `metadata(input)` / `metadataSync(input)`
117
+ ---
129
118
 
130
- Get image metadata.
119
+ ## Benchmarks
131
120
 
132
- ```typescript
133
- const info = await metadata(imageBuffer);
134
- // { width: 1920, height: 1080, format: 'jpeg', hasAlpha: false, ... }
135
- ```
121
+ Tested on Apple M1 Pro with Bun 1.3.3 (compared to sharp v0.34.5):
136
122
 
137
- ### `resize(input, options)` / `resizeSync(input, options)`
123
+ ### Metadata Extraction
138
124
 
139
- Resize an image.
125
+ | Operation | bun-image-turbo | sharp | Speedup |
126
+ |-----------|---------------:|------:|:-------:|
127
+ | WebP Metadata | **0.004ms** | 3.4ms | **950x** |
128
+ | JPEG Metadata | **0.003ms** | 0.1ms | **38x** |
129
+ | PNG Metadata | **0.002ms** | 0.08ms | **40x** |
140
130
 
141
- ```typescript
142
- // Resize by width (maintains aspect ratio)
143
- const resized = await resize(imageBuffer, { width: 800 });
144
-
145
- // Resize by height
146
- const resized = await resize(imageBuffer, { height: 600 });
147
-
148
- // Resize with specific dimensions
149
- const resized = await resize(imageBuffer, {
150
- width: 800,
151
- height: 600,
152
- fit: 'cover', // 'cover' | 'contain' | 'fill' | 'inside' | 'outside'
153
- filter: 'lanczos3' // 'nearest' | 'bilinear' | 'catmullRom' | 'mitchell' | 'lanczos3'
154
- });
155
- ```
131
+ ### Image Processing
132
+
133
+ | Operation | bun-image-turbo | sharp | Speedup |
134
+ |-----------|---------------:|------:|:-------:|
135
+ | 50 Concurrent Ops | **62ms** | 160ms | **2.6x** |
136
+ | Transform Pipeline | **12.2ms** | 19.1ms | **1.6x** |
137
+ | 1MB JPEG → 800px | **12.6ms** | 20.3ms | **1.6x** |
138
+ | Thumbnail (200px) | **8.8ms** | 10.7ms | **1.2x** |
156
139
 
157
- ### `toJpeg(input, options?)` / `toJpegSync(input, options?)`
140
+ ### HEIC Support (Exclusive)
158
141
 
159
- Convert to JPEG.
142
+ | Operation | Time | Notes |
143
+ |-----------|-----:|:------|
144
+ | HEIC Metadata | **0.1ms** | Header-only parsing |
145
+ | HEIC → JPEG | **169ms** | Full quality conversion |
146
+ | HEIC → 800px | **138ms** | Shrink-on-decode |
147
+ | HEIC → Thumbnail | **137ms** | Fast 200px generation |
160
148
 
161
- ```typescript
162
- const jpeg = await toJpeg(imageBuffer, { quality: 85 });
163
- ```
149
+ > **sharp does NOT support HEIC/HEIF files!** bun-image-turbo is the only high-performance library with native HEIC support.
164
150
 
165
- ### `toPng(input, options?)` / `toPngSync(input, options?)`
151
+ **[Full benchmark details →](https://nexus-aissam.github.io/bun-image-turbo/guide/performance)**
166
152
 
167
- Convert to PNG.
153
+ ---
168
154
 
169
- ```typescript
170
- const png = await toPng(imageBuffer, { compression: 6 });
171
- ```
155
+ ## Technology Stack
172
156
 
173
- ### `toWebp(input, options?)` / `toWebpSync(input, options?)`
157
+ | Component | Technology | Benefit |
158
+ |-----------|------------|---------|
159
+ | **JPEG Codec** | TurboJPEG (libjpeg-turbo) | SIMD acceleration (SSE2/AVX2/NEON) |
160
+ | **Resize Engine** | fast_image_resize + Rayon | Multi-threaded with adaptive algorithms |
161
+ | **WebP Codec** | libwebp bindings | Google's optimized encoder/decoder |
162
+ | **HEIC Decoder** | libheif-rs | Native Apple format support |
163
+ | **Node Bindings** | napi-rs | Zero-copy buffer handling |
174
164
 
175
- Convert to WebP.
165
+ **[Architecture deep dive →](https://nexus-aissam.github.io/bun-image-turbo/guide/architecture)**
176
166
 
177
- ```typescript
178
- // Lossy WebP
179
- const webp = await toWebp(imageBuffer, { quality: 80 });
167
+ ---
180
168
 
181
- // Lossless WebP
182
- const lossless = await toWebp(imageBuffer, { lossless: true });
183
- ```
169
+ ## Features
184
170
 
185
- ### `transform(input, options)` / `transformSync(input, options)`
171
+ - **TurboJPEG with SIMD** - 2-6x faster JPEG encoding/decoding via libjpeg-turbo
172
+ - **Shrink-on-Decode** - Decode JPEG/HEIC at reduced resolution for faster thumbnails
173
+ - **Adaptive Algorithms** - Auto-selects optimal resize filter based on scale factor
174
+ - **Native HEIC Support** - The only high-performance library with HEIC/HEIF decoding
175
+ - **Blurhash Generation** - Built-in compact placeholder generation
176
+ - **Multi-Step Resize** - Progressive halving for large scale reductions
177
+ - **Async & Sync APIs** - Both async and sync versions available
178
+ - **TypeScript First** - Full TypeScript support with strict types
179
+ - **Cross-Platform** - macOS, Linux, Windows support
186
180
 
187
- Apply multiple transformations in a single operation (most efficient).
181
+ ---
188
182
 
189
- ```typescript
190
- const result = await transform(imageBuffer, {
191
- // Resize
192
- resize: { width: 800, height: 600, fit: 'cover' },
183
+ ## API Overview
193
184
 
194
- // Transformations
195
- rotate: 90, // 90, 180, or 270 degrees
196
- flipH: true, // Flip horizontally
197
- flipV: false, // Flip vertically
198
- grayscale: true, // Convert to grayscale
199
- blur: 5, // Blur radius (0-100)
200
- sharpen: 10, // Sharpen amount (0-100)
201
- brightness: 10, // Brightness (-100 to 100)
202
- contrast: 5, // Contrast (-100 to 100)
203
-
204
- // Output format
205
- output: {
206
- format: 'webp',
207
- webp: { quality: 85 }
208
- }
209
- });
210
- ```
185
+ | Function | Description | Docs |
186
+ |----------|-------------|------|
187
+ | `metadata()` | Get image info (ultra-fast) | [→](https://nexus-aissam.github.io/bun-image-turbo/api/metadata) |
188
+ | `resize()` | Resize image (outputs PNG) | [→](https://nexus-aissam.github.io/bun-image-turbo/api/resize) |
189
+ | `transform()` | Multi-operation pipeline | [→](https://nexus-aissam.github.io/bun-image-turbo/api/transform) |
190
+ | `toJpeg()` | Convert to JPEG | [→](https://nexus-aissam.github.io/bun-image-turbo/api/to-jpeg) |
191
+ | `toPng()` | Convert to PNG | [→](https://nexus-aissam.github.io/bun-image-turbo/api/to-png) |
192
+ | `toWebp()` | Convert to WebP | [→](https://nexus-aissam.github.io/bun-image-turbo/api/to-webp) |
193
+ | `blurhash()` | Generate placeholder hash | [→](https://nexus-aissam.github.io/bun-image-turbo/api/blurhash) |
211
194
 
212
- ### `blurhash(input, componentsX?, componentsY?)` / `blurhashSync(...)`
195
+ All functions have sync variants (`metadataSync`, `resizeSync`, etc.)
213
196
 
214
- Generate a blurhash placeholder string.
197
+ **[Full API Reference →](https://nexus-aissam.github.io/bun-image-turbo/api/)**
215
198
 
216
- ```typescript
217
- const { hash, width, height } = await blurhash(imageBuffer, 4, 3);
218
- console.log(hash); // "LEHV6nWB2yk8pyo0adR*.7kCMdnj"
219
- ```
199
+ ---
200
+
201
+ ## Supported Formats
220
202
 
221
- ### `version()`
203
+ | Format | Read | Write | Notes |
204
+ |--------|:----:|:-----:|-------|
205
+ | JPEG | ✅ | ✅ | TurboJPEG with SIMD |
206
+ | PNG | ✅ | ✅ | Adaptive compression |
207
+ | WebP | ✅ | ✅ | Lossy & lossless |
208
+ | HEIC/HEIF | ✅ | ❌ | macOS ARM64 only |
209
+ | AVIF | ✅ | ❌ | Via libheif |
210
+ | GIF | ✅ | ✅ | Animated support |
211
+ | BMP | ✅ | ✅ | Full support |
212
+ | TIFF | ✅ | ❌ | Multi-page support |
213
+ | ICO | ✅ | ❌ | Multi-size icons |
222
214
 
223
- Get library version.
215
+ **[Format guide →](https://nexus-aissam.github.io/bun-image-turbo/guide/formats)**
224
216
 
225
- ```typescript
226
- console.log(version()); // "1.0.0"
217
+ ---
218
+
219
+ ## Platform Support
220
+
221
+ Prebuilt binaries are available for all major platforms:
222
+
223
+ | Platform | Architecture | Supported | HEIC |
224
+ |----------|--------------|:---------:|:----:|
225
+ | macOS | ARM64 (M1/M2/M3/M4/M5) | ✅ | ✅ |
226
+ | macOS | x64 (Intel) | ✅ | ❌ |
227
+ | Linux | x64 (glibc) | ✅ | ❌ |
228
+ | Linux | x64 (musl/Alpine) | ✅ | ❌ |
229
+ | Linux | ARM64 (glibc) | ✅ | ❌ |
230
+ | Windows | x64 | ✅ | ❌ |
231
+ | Windows | ARM64 | ✅ | ❌ |
232
+
233
+ > **Note:** HEIC/HEIF decoding is only available on macOS ARM64. All other formats work on all platforms.
234
+
235
+ ---
236
+
237
+ ## Examples
238
+
239
+ ```bash
240
+ cd examples
241
+ bun install
242
+
243
+ bun run basic # Core functionality
244
+ bun run heic # HEIC conversion (macOS ARM64)
245
+ bun run api # HTTP image server
246
+ bun run batch # Parallel batch processing
227
247
  ```
228
248
 
229
- ## Options
249
+ | Example | Description |
250
+ |---------|-------------|
251
+ | [basic-usage.ts](./examples/basic-usage.ts) | Metadata, resize, convert, transform |
252
+ | [heic-conversion.ts](./examples/heic-conversion.ts) | iPhone photo conversion |
253
+ | [api-endpoint.ts](./examples/api-endpoint.ts) | HTTP image processing server |
254
+ | [batch-processing.ts](./examples/batch-processing.ts) | Parallel multi-file processing |
230
255
 
231
- ### Resize Options
256
+ **[All examples →](https://nexus-aissam.github.io/bun-image-turbo/examples/)**
232
257
 
233
- | Option | Type | Default | Description |
234
- |--------|------|---------|-------------|
235
- | `width` | `number` | - | Target width (optional if height provided) |
236
- | `height` | `number` | - | Target height (optional if width provided) |
237
- | `filter` | `string` | `'lanczos3'` | Resize algorithm |
238
- | `fit` | `string` | `'cover'` | How to fit the image |
258
+ ---
239
259
 
240
- ### Filter Types
260
+ ## Documentation
241
261
 
242
- - `nearest` - Fastest, lowest quality
243
- - `bilinear` - Fast, good quality
244
- - `catmullRom` - Balanced speed and quality
245
- - `mitchell` - Good for downscaling
246
- - `lanczos3` - Highest quality, slower (default)
262
+ <table>
263
+ <tr>
264
+ <td width="50%">
247
265
 
248
- ### Fit Modes
266
+ ### Online Documentation
249
267
 
250
- - `cover` - Resize to cover target dimensions (may crop)
251
- - `contain` - Resize to fit within target (may have padding)
252
- - `fill` - Resize to exact dimensions (may distort)
253
- - `inside` - Resize only if larger than target
254
- - `outside` - Resize only if smaller than target
268
+ Full documentation with examples, API reference, and guides:
255
269
 
256
- ### JPEG Options
270
+ **[nexus-aissam.github.io/bun-image-turbo](https://nexus-aissam.github.io/bun-image-turbo/)**
257
271
 
258
- | Option | Type | Default | Description |
259
- |--------|------|---------|-------------|
260
- | `quality` | `number` | `80` | Quality 1-100 |
272
+ - [Getting Started](https://nexus-aissam.github.io/bun-image-turbo/guide/)
273
+ - [API Reference](https://nexus-aissam.github.io/bun-image-turbo/api/)
274
+ - [Examples](https://nexus-aissam.github.io/bun-image-turbo/examples/)
275
+ - [Architecture](https://nexus-aissam.github.io/bun-image-turbo/guide/architecture)
276
+ - [Performance](https://nexus-aissam.github.io/bun-image-turbo/guide/performance)
261
277
 
262
- ### PNG Options
278
+ </td>
279
+ <td width="50%">
263
280
 
264
- | Option | Type | Default | Description |
265
- |--------|------|---------|-------------|
266
- | `compression` | `number` | `6` | Compression level 0-9 |
281
+ ### Offline Documentation
267
282
 
268
- ### WebP Options
283
+ Documentation is also available in the [`docs/`](./docs/) folder:
269
284
 
270
- | Option | Type | Default | Description |
271
- |--------|------|---------|-------------|
272
- | `quality` | `number` | `80` | Quality 1-100 (lossy) |
273
- | `lossless` | `boolean` | `false` | Use lossless compression |
285
+ - [Guide](./docs/guide/)
286
+ - [API](./docs/api/)
287
+ - [Examples](./docs/examples/)
274
288
 
275
- ## Supported Formats
289
+ View locally:
276
290
 
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 |
286
-
287
- ## Supported Platforms
288
-
289
- | Platform | Architecture | Support |
290
- |----------|--------------|---------|
291
- | macOS | ARM64 (M1/M2/M3) | Yes |
292
- | macOS | x64 (Intel) | Yes |
293
- | Linux | x64 (glibc) | Yes |
294
- | Linux | x64 (musl/Alpine) | Yes |
295
- | Linux | ARM64 (glibc) | Yes |
296
- | Linux | ARM64 (musl) | Yes |
297
- | Windows | x64 | Yes |
298
-
299
- ## Development
291
+ ```bash
292
+ cd docs
293
+ bun install
294
+ bun run docs:dev
295
+ ```
296
+
297
+ </td>
298
+ </tr>
299
+ </table>
300
+
301
+ ---
302
+
303
+ ## Contributing
300
304
 
301
305
  ```bash
302
- # Clone the repository
306
+ # Clone
303
307
  git clone https://github.com/nexus-aissam/bun-image-turbo.git
304
308
  cd bun-image-turbo
305
309
 
306
310
  # Install dependencies
307
311
  bun install
308
312
 
309
- # Build native module (requires Rust)
313
+ # Build native module (requires Rust 1.70+)
310
314
  bun run build
311
315
 
312
316
  # Build TypeScript
313
317
  bun run build:ts
314
318
 
315
319
  # Run tests
316
- bun test
320
+ bun test test/
317
321
  ```
318
322
 
319
323
  ### Requirements
@@ -321,19 +325,35 @@ bun test
321
325
  - Bun 1.0+ or Node.js 18+
322
326
  - Rust 1.70+ (for building from source)
323
327
 
328
+ ---
329
+
324
330
  ## License
325
331
 
326
332
  MIT License - see [LICENSE](LICENSE) for details.
327
333
 
334
+ ---
335
+
328
336
  ## Author
329
337
 
330
- Aissam Irhir ([@nexus-aissam](https://github.com/nexus-aissam))
338
+ **Aissam Irhir** ([@nexus-aissam](https://github.com/nexus-aissam))
339
+
340
+ ---
331
341
 
332
342
  ## Acknowledgments
333
343
 
334
344
  - [turbojpeg](https://crates.io/crates/turbojpeg) - libjpeg-turbo bindings with SIMD
335
345
  - [image](https://crates.io/crates/image) - Rust image processing library
336
- - [fast_image_resize](https://crates.io/crates/fast_image_resize) - Fast image resizing
346
+ - [fast_image_resize](https://crates.io/crates/fast_image_resize) - Fast image resizing with Rayon
337
347
  - [webp](https://crates.io/crates/webp) - WebP encoding/decoding
348
+ - [libheif-rs](https://crates.io/crates/libheif-rs) - HEIC/HEIF decoding via libheif
338
349
  - [blurhash](https://crates.io/crates/blurhash) - Blurhash generation
339
350
  - [napi-rs](https://napi.rs/) - Rust bindings for Node.js
351
+
352
+ ---
353
+
354
+ <p align="center">
355
+ <a href="https://nexus-aissam.github.io/bun-image-turbo/">Documentation</a> •
356
+ <a href="https://nexus-aissam.github.io/bun-image-turbo/api/">API</a> •
357
+ <a href="https://www.npmjs.com/package/bun-image-turbo">npm</a> •
358
+ <a href="https://github.com/nexus-aissam/bun-image-turbo">GitHub</a>
359
+ </p>
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,10 +1,20 @@
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.2",
4
+ "author": "Aissam Irhir <aissamirhir@gmail.com>",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/nexus-aissam/bun-image-turbo.git"
8
+ },
5
9
  "main": "./dist/index.js",
6
10
  "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
11
+ "devDependencies": {
12
+ "@napi-rs/cli": "^2.18.4",
13
+ "@types/bun": "latest",
14
+ "sharp": "^0.34.5",
15
+ "tsup": "^8.4.0",
16
+ "typescript": "^5.9.0"
17
+ },
8
18
  "exports": {
9
19
  ".": {
10
20
  "import": {
@@ -17,9 +27,43 @@
17
27
  }
18
28
  }
19
29
  },
30
+ "bugs": {
31
+ "url": "https://github.com/nexus-aissam/bun-image-turbo/issues"
32
+ },
33
+ "description": "High-performance image processing for Bun and Node.js - resize, convert, compress with HEIC, WebP, AVIF, PNG, JPEG support",
34
+ "engines": {
35
+ "node": ">=18.0.0"
36
+ },
20
37
  "files": [
21
38
  "dist"
22
39
  ],
40
+ "homepage": "https://nexus-aissam.github.io/bun-image-turbo/",
41
+ "keywords": [
42
+ "image",
43
+ "resize",
44
+ "compress",
45
+ "heic",
46
+ "heif",
47
+ "webp",
48
+ "avif",
49
+ "png",
50
+ "jpeg",
51
+ "jpg",
52
+ "gif",
53
+ "iphone",
54
+ "thumbnail",
55
+ "crop",
56
+ "convert",
57
+ "processing",
58
+ "bun",
59
+ "nodejs",
60
+ "rust",
61
+ "napi",
62
+ "native",
63
+ "fast",
64
+ "turbo"
65
+ ],
66
+ "license": "MIT",
23
67
  "napi": {
24
68
  "name": "image-turbo",
25
69
  "binaryName": "image-turbo",
@@ -46,55 +90,14 @@
46
90
  "lint": "eslint src",
47
91
  "clean": "rm -rf dist *.node npm"
48
92
  },
49
- "keywords": [
50
- "image",
51
- "resize",
52
- "compress",
53
- "webp",
54
- "avif",
55
- "png",
56
- "jpeg",
57
- "jpg",
58
- "gif",
59
- "thumbnail",
60
- "crop",
61
- "convert",
62
- "processing",
63
- "bun",
64
- "nodejs",
65
- "rust",
66
- "napi",
67
- "native",
68
- "fast",
69
- "turbo"
70
- ],
71
- "author": "Aissam Irhir <aissamirhir@gmail.com>",
72
- "license": "MIT",
73
- "repository": {
74
- "type": "git",
75
- "url": "git+https://github.com/nexus-aissam/bun-image-turbo.git"
76
- },
77
- "bugs": {
78
- "url": "https://github.com/nexus-aissam/bun-image-turbo/issues"
79
- },
80
- "homepage": "https://github.com/nexus-aissam/bun-image-turbo#readme",
81
- "engines": {
82
- "node": ">=18.0.0"
83
- },
84
- "devDependencies": {
85
- "@napi-rs/cli": "^2.18.4",
86
- "@types/bun": "latest",
87
- "sharp": "^0.34.5",
88
- "tsup": "^8.4.0",
89
- "typescript": "^5.9.0"
90
- },
93
+ "types": "./dist/index.d.ts",
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.2",
96
+ "bun-image-turbo-darwin-x64": "1.2.2",
97
+ "bun-image-turbo-linux-arm64-gnu": "1.2.2",
98
+ "bun-image-turbo-linux-x64-gnu": "1.2.2",
99
+ "bun-image-turbo-linux-x64-musl": "1.2.2",
100
+ "bun-image-turbo-win32-arm64-msvc": "1.2.2",
101
+ "bun-image-turbo-win32-x64-msvc": "1.2.2"
99
102
  }
100
103
  }