bun-image-turbo 1.2.0 → 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.
Files changed (2) hide show
  1. package/README.md +247 -241
  2. package/package.json +53 -53
package/README.md CHANGED
@@ -1,332 +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, **HEIC/HEIF** support
16
- - **HEIC Support** - Read iPhone photos and HEIC/HEIF files natively
17
- - **Resize** - High-quality resizing with multiple algorithms (Lanczos3, Mitchell, etc.)
18
- - **Transform** - Rotate, flip, blur, sharpen, grayscale, brightness, contrast
19
- - **Blurhash** - Generate compact image placeholders
20
- - **Async & Sync** - Both async and sync APIs available
21
- - **TypeScript** - Full TypeScript support with strict types
22
- - **Cross-platform** - macOS, Linux, Windows support
23
-
24
- ## Benchmarks
25
-
26
- Tested on Apple M1 Pro with Bun 1.3.3 (compared to sharp v0.34.5):
27
-
28
- ### Performance Summary
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
- └──────────────────────────────────────────────────────────────────────────────┘
42
- ```
43
-
44
- ### Detailed Benchmarks
45
-
46
- | Operation | bun-image-turbo | sharp | Speedup |
47
- |-----------|---------------:|------:|:-------:|
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!
71
-
72
- ### Key Strengths
73
-
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
81
- - Zero-copy buffer handling with Rust
82
-
83
- > Run benchmarks yourself: `bun run benchmarks/final_comparison.ts`
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
+ ---
84
60
 
85
61
  ## Installation
86
62
 
87
63
  ```bash
88
- # Using Bun (recommended)
64
+ # Bun (recommended)
89
65
  bun add bun-image-turbo
90
66
 
91
- # Using npm
67
+ # npm
92
68
  npm install bun-image-turbo
93
69
 
94
- # Using yarn
70
+ # yarn
95
71
  yarn add bun-image-turbo
96
72
 
97
- # Using pnpm
73
+ # pnpm
98
74
  pnpm add bun-image-turbo
99
75
  ```
100
76
 
77
+ Prebuilt binaries are available for **all major platforms** - no compilation needed.
78
+
79
+ ---
80
+
101
81
  ## Quick Start
102
82
 
103
83
  ```typescript
104
- import { resize, toWebp, metadata, transform } from 'bun-image-turbo';
84
+ import { metadata, resize, transform, toWebp, blurhash } from 'bun-image-turbo';
105
85
 
106
86
  // Read image
107
- const input = await Bun.file('input.jpg').arrayBuffer();
108
- const buffer = Buffer.from(input);
87
+ const buffer = Buffer.from(await Bun.file('photo.jpg').arrayBuffer());
109
88
 
110
- // Get metadata
89
+ // Get metadata (ultra-fast, header-only)
111
90
  const info = await metadata(buffer);
112
91
  console.log(`${info.width}x${info.height} ${info.format}`);
113
92
 
114
- // Resize image
115
- const resized = await resize(buffer, { width: 800 });
93
+ // Resize with shrink-on-decode optimization
94
+ const thumbnail = await resize(buffer, { width: 200 });
116
95
 
117
- // Convert to WebP
96
+ // Convert to WebP (50-80% smaller than JPEG)
118
97
  const webp = await toWebp(buffer, { quality: 85 });
119
98
 
120
- // Apply multiple transformations
99
+ // Full transform pipeline
121
100
  const result = await transform(buffer, {
122
- resize: { width: 400, height: 300 },
101
+ resize: { width: 800, height: 600, fit: 'cover' },
123
102
  rotate: 90,
124
103
  grayscale: true,
125
- output: { format: 'webp', webp: { quality: 80 } }
104
+ sharpen: 10,
105
+ output: { format: 'webp', webp: { quality: 85 } }
126
106
  });
127
107
 
108
+ // Generate blurhash placeholder
109
+ const { hash } = await blurhash(buffer, 4, 3);
110
+
128
111
  // Save result
129
112
  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);
135
113
  ```
136
114
 
137
- ## API Reference
115
+ **[See more examples →](https://nexus-aissam.github.io/bun-image-turbo/examples/)**
138
116
 
139
- ### `metadata(input)` / `metadataSync(input)`
117
+ ---
140
118
 
141
- Get image metadata.
119
+ ## Benchmarks
142
120
 
143
- ```typescript
144
- const info = await metadata(imageBuffer);
145
- // { width: 1920, height: 1080, format: 'jpeg', hasAlpha: false, ... }
146
- ```
121
+ Tested on Apple M1 Pro with Bun 1.3.3 (compared to sharp v0.34.5):
147
122
 
148
- ### `resize(input, options)` / `resizeSync(input, options)`
123
+ ### Metadata Extraction
149
124
 
150
- 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** |
151
130
 
152
- ```typescript
153
- // Resize by width (maintains aspect ratio)
154
- const resized = await resize(imageBuffer, { width: 800 });
155
-
156
- // Resize by height
157
- const resized = await resize(imageBuffer, { height: 600 });
158
-
159
- // Resize with specific dimensions
160
- const resized = await resize(imageBuffer, {
161
- width: 800,
162
- height: 600,
163
- fit: 'cover', // 'cover' | 'contain' | 'fill' | 'inside' | 'outside'
164
- filter: 'lanczos3' // 'nearest' | 'bilinear' | 'catmullRom' | 'mitchell' | 'lanczos3'
165
- });
166
- ```
131
+ ### Image Processing
167
132
 
168
- ### `toJpeg(input, options?)` / `toJpegSync(input, options?)`
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** |
169
139
 
170
- Convert to JPEG.
140
+ ### HEIC Support (Exclusive)
171
141
 
172
- ```typescript
173
- const jpeg = await toJpeg(imageBuffer, { quality: 85 });
174
- ```
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 |
175
148
 
176
- ### `toPng(input, options?)` / `toPngSync(input, options?)`
149
+ > **sharp does NOT support HEIC/HEIF files!** bun-image-turbo is the only high-performance library with native HEIC support.
177
150
 
178
- Convert to PNG.
151
+ **[Full benchmark details →](https://nexus-aissam.github.io/bun-image-turbo/guide/performance)**
179
152
 
180
- ```typescript
181
- const png = await toPng(imageBuffer, { compression: 6 });
182
- ```
153
+ ---
183
154
 
184
- ### `toWebp(input, options?)` / `toWebpSync(input, options?)`
155
+ ## Technology Stack
185
156
 
186
- Convert to WebP.
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 |
187
164
 
188
- ```typescript
189
- // Lossy WebP
190
- const webp = await toWebp(imageBuffer, { quality: 80 });
165
+ **[Architecture deep dive →](https://nexus-aissam.github.io/bun-image-turbo/guide/architecture)**
191
166
 
192
- // Lossless WebP
193
- const lossless = await toWebp(imageBuffer, { lossless: true });
194
- ```
167
+ ---
195
168
 
196
- ### `transform(input, options)` / `transformSync(input, options)`
169
+ ## Features
197
170
 
198
- Apply multiple transformations in a single operation (most efficient).
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
199
180
 
200
- ```typescript
201
- const result = await transform(imageBuffer, {
202
- // Resize
203
- resize: { width: 800, height: 600, fit: 'cover' },
181
+ ---
204
182
 
205
- // Transformations
206
- rotate: 90, // 90, 180, or 270 degrees
207
- flipH: true, // Flip horizontally
208
- flipV: false, // Flip vertically
209
- grayscale: true, // Convert to grayscale
210
- blur: 5, // Blur radius (0-100)
211
- sharpen: 10, // Sharpen amount (0-100)
212
- brightness: 10, // Brightness (-100 to 100)
213
- contrast: 5, // Contrast (-100 to 100)
214
-
215
- // Output format
216
- output: {
217
- format: 'webp',
218
- webp: { quality: 85 }
219
- }
220
- });
221
- ```
183
+ ## API Overview
222
184
 
223
- ### `blurhash(input, componentsX?, componentsY?)` / `blurhashSync(...)`
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) |
224
194
 
225
- Generate a blurhash placeholder string.
195
+ All functions have sync variants (`metadataSync`, `resizeSync`, etc.)
226
196
 
227
- ```typescript
228
- const { hash, width, height } = await blurhash(imageBuffer, 4, 3);
229
- console.log(hash); // "LEHV6nWB2yk8pyo0adR*.7kCMdnj"
230
- ```
197
+ **[Full API Reference →](https://nexus-aissam.github.io/bun-image-turbo/api/)**
231
198
 
232
- ### `version()`
199
+ ---
233
200
 
234
- Get library version.
201
+ ## Supported Formats
235
202
 
236
- ```typescript
237
- console.log(version()); // "1.0.0"
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 |
214
+
215
+ **[Format guide →](https://nexus-aissam.github.io/bun-image-turbo/guide/formats)**
216
+
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
238
247
  ```
239
248
 
240
- ## 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 |
241
255
 
242
- ### Resize Options
256
+ **[All examples →](https://nexus-aissam.github.io/bun-image-turbo/examples/)**
243
257
 
244
- | Option | Type | Default | Description |
245
- |--------|------|---------|-------------|
246
- | `width` | `number` | - | Target width (optional if height provided) |
247
- | `height` | `number` | - | Target height (optional if width provided) |
248
- | `filter` | `string` | `'lanczos3'` | Resize algorithm |
249
- | `fit` | `string` | `'cover'` | How to fit the image |
258
+ ---
250
259
 
251
- ### Filter Types
260
+ ## Documentation
252
261
 
253
- - `nearest` - Fastest, lowest quality
254
- - `bilinear` - Fast, good quality
255
- - `catmullRom` - Balanced speed and quality
256
- - `mitchell` - Good for downscaling
257
- - `lanczos3` - Highest quality, slower (default)
262
+ <table>
263
+ <tr>
264
+ <td width="50%">
258
265
 
259
- ### Fit Modes
266
+ ### Online Documentation
260
267
 
261
- - `cover` - Resize to cover target dimensions (may crop)
262
- - `contain` - Resize to fit within target (may have padding)
263
- - `fill` - Resize to exact dimensions (may distort)
264
- - `inside` - Resize only if larger than target
265
- - `outside` - Resize only if smaller than target
268
+ Full documentation with examples, API reference, and guides:
266
269
 
267
- ### JPEG Options
270
+ **[nexus-aissam.github.io/bun-image-turbo](https://nexus-aissam.github.io/bun-image-turbo/)**
268
271
 
269
- | Option | Type | Default | Description |
270
- |--------|------|---------|-------------|
271
- | `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)
272
277
 
273
- ### PNG Options
278
+ </td>
279
+ <td width="50%">
274
280
 
275
- | Option | Type | Default | Description |
276
- |--------|------|---------|-------------|
277
- | `compression` | `number` | `6` | Compression level 0-9 |
281
+ ### Offline Documentation
278
282
 
279
- ### WebP Options
283
+ Documentation is also available in the [`docs/`](./docs/) folder:
280
284
 
281
- | Option | Type | Default | Description |
282
- |--------|------|---------|-------------|
283
- | `quality` | `number` | `80` | Quality 1-100 (lossy) |
284
- | `lossless` | `boolean` | `false` | Use lossless compression |
285
+ - [Guide](./docs/guide/)
286
+ - [API](./docs/api/)
287
+ - [Examples](./docs/examples/)
285
288
 
286
- ## Supported Formats
289
+ View locally:
287
290
 
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 |
299
-
300
- ## Supported Platforms
301
-
302
- | Platform | Architecture | Support |
303
- |----------|--------------|---------|
304
- | macOS | ARM64 (M1/M2/M3) | Yes |
305
- | macOS | x64 (Intel) | Yes |
306
- | Linux | x64 (glibc) | Yes |
307
- | Linux | x64 (musl/Alpine) | Yes |
308
- | Linux | ARM64 (glibc) | Yes |
309
- | Linux | ARM64 (musl) | Yes |
310
- | Windows | x64 | Yes |
311
-
312
- ## 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
313
304
 
314
305
  ```bash
315
- # Clone the repository
306
+ # Clone
316
307
  git clone https://github.com/nexus-aissam/bun-image-turbo.git
317
308
  cd bun-image-turbo
318
309
 
319
310
  # Install dependencies
320
311
  bun install
321
312
 
322
- # Build native module (requires Rust)
313
+ # Build native module (requires Rust 1.70+)
323
314
  bun run build
324
315
 
325
316
  # Build TypeScript
326
317
  bun run build:ts
327
318
 
328
319
  # Run tests
329
- bun test
320
+ bun test test/
330
321
  ```
331
322
 
332
323
  ### Requirements
@@ -334,20 +325,35 @@ bun test
334
325
  - Bun 1.0+ or Node.js 18+
335
326
  - Rust 1.70+ (for building from source)
336
327
 
328
+ ---
329
+
337
330
  ## License
338
331
 
339
332
  MIT License - see [LICENSE](LICENSE) for details.
340
333
 
334
+ ---
335
+
341
336
  ## Author
342
337
 
343
- Aissam Irhir ([@nexus-aissam](https://github.com/nexus-aissam))
338
+ **Aissam Irhir** ([@nexus-aissam](https://github.com/nexus-aissam))
339
+
340
+ ---
344
341
 
345
342
  ## Acknowledgments
346
343
 
347
344
  - [turbojpeg](https://crates.io/crates/turbojpeg) - libjpeg-turbo bindings with SIMD
348
345
  - [image](https://crates.io/crates/image) - Rust image processing library
349
- - [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
350
347
  - [webp](https://crates.io/crates/webp) - WebP encoding/decoding
351
348
  - [libheif-rs](https://crates.io/crates/libheif-rs) - HEIC/HEIF decoding via libheif
352
349
  - [blurhash](https://crates.io/crates/blurhash) - Blurhash generation
353
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/package.json CHANGED
@@ -1,10 +1,20 @@
1
1
  {
2
2
  "name": "bun-image-turbo",
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",
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,35 +27,17 @@
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
  ],
23
- "napi": {
24
- "name": "image-turbo",
25
- "binaryName": "image-turbo",
26
- "packageName": "bun-image-turbo",
27
- "targets": [
28
- "x86_64-apple-darwin",
29
- "aarch64-apple-darwin",
30
- "x86_64-pc-windows-msvc",
31
- "aarch64-pc-windows-msvc",
32
- "x86_64-unknown-linux-gnu",
33
- "aarch64-unknown-linux-gnu",
34
- "x86_64-unknown-linux-musl"
35
- ]
36
- },
37
- "scripts": {
38
- "build": "napi build --platform --release",
39
- "build:debug": "napi build --platform",
40
- "build:ts": "tsup src/index.ts --format cjs,esm --dts --clean",
41
- "build:all": "bun run build && bun run build:ts",
42
- "artifacts": "napi artifacts",
43
- "version": "napi version",
44
- "test": "bun test",
45
- "bench": "bun run benchmarks/bench.ts",
46
- "lint": "eslint src",
47
- "clean": "rm -rf dist *.node npm"
48
- },
40
+ "homepage": "https://nexus-aissam.github.io/bun-image-turbo/",
49
41
  "keywords": [
50
42
  "image",
51
43
  "resize",
@@ -71,33 +63,41 @@
71
63
  "fast",
72
64
  "turbo"
73
65
  ],
74
- "author": "Aissam Irhir <aissamirhir@gmail.com>",
75
66
  "license": "MIT",
76
- "repository": {
77
- "type": "git",
78
- "url": "git+https://github.com/nexus-aissam/bun-image-turbo.git"
79
- },
80
- "bugs": {
81
- "url": "https://github.com/nexus-aissam/bun-image-turbo/issues"
82
- },
83
- "homepage": "https://github.com/nexus-aissam/bun-image-turbo#readme",
84
- "engines": {
85
- "node": ">=18.0.0"
67
+ "napi": {
68
+ "name": "image-turbo",
69
+ "binaryName": "image-turbo",
70
+ "packageName": "bun-image-turbo",
71
+ "targets": [
72
+ "x86_64-apple-darwin",
73
+ "aarch64-apple-darwin",
74
+ "x86_64-pc-windows-msvc",
75
+ "aarch64-pc-windows-msvc",
76
+ "x86_64-unknown-linux-gnu",
77
+ "aarch64-unknown-linux-gnu",
78
+ "x86_64-unknown-linux-musl"
79
+ ]
86
80
  },
87
- "devDependencies": {
88
- "@napi-rs/cli": "^2.18.4",
89
- "@types/bun": "latest",
90
- "sharp": "^0.34.5",
91
- "tsup": "^8.4.0",
92
- "typescript": "^5.9.0"
81
+ "scripts": {
82
+ "build": "napi build --platform --release",
83
+ "build:debug": "napi build --platform",
84
+ "build:ts": "tsup src/index.ts --format cjs,esm --dts --clean",
85
+ "build:all": "bun run build && bun run build:ts",
86
+ "artifacts": "napi artifacts",
87
+ "version": "napi version",
88
+ "test": "bun test",
89
+ "bench": "bun run benchmarks/bench.ts",
90
+ "lint": "eslint src",
91
+ "clean": "rm -rf dist *.node npm"
93
92
  },
93
+ "types": "./dist/index.d.ts",
94
94
  "optionalDependencies": {
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"
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"
102
102
  }
103
103
  }