bun-image-turbo 1.2.0 → 1.3.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 +292 -240
- package/dist/index.d.mts +76 -1
- package/dist/index.d.ts +76 -1
- package/dist/index.js +29 -2
- package/dist/index.mjs +24 -1
- package/package.json +53 -53
package/README.md
CHANGED
|
@@ -1,332 +1,368 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
|
49
|
-
|
|
50
|
-
| **
|
|
51
|
-
| **
|
|
52
|
-
| **
|
|
53
|
-
| **
|
|
54
|
-
| **
|
|
55
|
-
| **
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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>EXIF metadata writing</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
|
+
| EXIF Write | **<0.3ms** | Native EXIF embedding |
|
|
40
|
+
| HEIC Support | **Exclusive** | Only lib with native HEIC |
|
|
41
|
+
|
|
42
|
+
> **bun-image-turbo** is the fastest image processing library for JavaScript. Period.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Quick Links
|
|
47
|
+
|
|
48
|
+
| Resource | Link |
|
|
49
|
+
|----------|------|
|
|
50
|
+
| **Documentation** | [nexus-aissam.github.io/bun-image-turbo](https://nexus-aissam.github.io/bun-image-turbo/) |
|
|
51
|
+
| **API Reference** | [Full API Docs](https://nexus-aissam.github.io/bun-image-turbo/api/) |
|
|
52
|
+
| **Examples** | [Code Examples](https://nexus-aissam.github.io/bun-image-turbo/examples/) |
|
|
53
|
+
| **Getting Started** | [Installation Guide](https://nexus-aissam.github.io/bun-image-turbo/guide/) |
|
|
54
|
+
| **Architecture** | [Technical Deep Dive](https://nexus-aissam.github.io/bun-image-turbo/guide/architecture) |
|
|
55
|
+
| **Performance** | [Benchmarks & Optimization](https://nexus-aissam.github.io/bun-image-turbo/guide/performance) |
|
|
56
|
+
| **npm Package** | [npmjs.com/package/bun-image-turbo](https://www.npmjs.com/package/bun-image-turbo) |
|
|
57
|
+
| **GitHub** | [nexus-aissam/bun-image-turbo](https://github.com/nexus-aissam/bun-image-turbo) |
|
|
58
|
+
| **Changelog** | [Release Notes](https://nexus-aissam.github.io/bun-image-turbo/changelog) |
|
|
59
|
+
|
|
60
|
+
---
|
|
84
61
|
|
|
85
62
|
## Installation
|
|
86
63
|
|
|
87
64
|
```bash
|
|
88
|
-
#
|
|
65
|
+
# Bun (recommended)
|
|
89
66
|
bun add bun-image-turbo
|
|
90
67
|
|
|
91
|
-
#
|
|
68
|
+
# npm
|
|
92
69
|
npm install bun-image-turbo
|
|
93
70
|
|
|
94
|
-
#
|
|
71
|
+
# yarn
|
|
95
72
|
yarn add bun-image-turbo
|
|
96
73
|
|
|
97
|
-
#
|
|
74
|
+
# pnpm
|
|
98
75
|
pnpm add bun-image-turbo
|
|
99
76
|
```
|
|
100
77
|
|
|
78
|
+
Prebuilt binaries are available for **all major platforms** - no compilation needed.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
101
82
|
## Quick Start
|
|
102
83
|
|
|
103
84
|
```typescript
|
|
104
|
-
import { resize, toWebp,
|
|
85
|
+
import { metadata, resize, transform, toWebp, blurhash, writeExif } from 'bun-image-turbo';
|
|
105
86
|
|
|
106
87
|
// Read image
|
|
107
|
-
const
|
|
108
|
-
const buffer = Buffer.from(input);
|
|
88
|
+
const buffer = Buffer.from(await Bun.file('photo.jpg').arrayBuffer());
|
|
109
89
|
|
|
110
|
-
// Get metadata
|
|
90
|
+
// Get metadata (ultra-fast, header-only)
|
|
111
91
|
const info = await metadata(buffer);
|
|
112
92
|
console.log(`${info.width}x${info.height} ${info.format}`);
|
|
113
93
|
|
|
114
|
-
// Resize
|
|
115
|
-
const
|
|
94
|
+
// Resize with shrink-on-decode optimization
|
|
95
|
+
const thumbnail = await resize(buffer, { width: 200 });
|
|
116
96
|
|
|
117
|
-
// Convert to WebP
|
|
97
|
+
// Convert to WebP (50-80% smaller than JPEG)
|
|
118
98
|
const webp = await toWebp(buffer, { quality: 85 });
|
|
119
99
|
|
|
120
|
-
//
|
|
100
|
+
// Full transform pipeline
|
|
121
101
|
const result = await transform(buffer, {
|
|
122
|
-
resize: { width:
|
|
102
|
+
resize: { width: 800, height: 600, fit: 'cover' },
|
|
123
103
|
rotate: 90,
|
|
124
104
|
grayscale: true,
|
|
125
|
-
|
|
105
|
+
sharpen: 10,
|
|
106
|
+
output: { format: 'webp', webp: { quality: 85 } }
|
|
126
107
|
});
|
|
127
108
|
|
|
128
|
-
//
|
|
129
|
-
await
|
|
109
|
+
// Generate blurhash placeholder
|
|
110
|
+
const { hash } = await blurhash(buffer, 4, 3);
|
|
130
111
|
|
|
131
|
-
//
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
112
|
+
// Add EXIF metadata (perfect for AI images)
|
|
113
|
+
const withExif = await writeExif(webp, {
|
|
114
|
+
imageDescription: 'AI-generated sunset',
|
|
115
|
+
artist: 'Stable Diffusion XL',
|
|
116
|
+
software: 'ComfyUI',
|
|
117
|
+
userComment: JSON.stringify({ prompt: '...', seed: 12345 })
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Save result
|
|
121
|
+
await Bun.write('output.webp', withExif);
|
|
135
122
|
```
|
|
136
123
|
|
|
137
|
-
|
|
124
|
+
**[See more examples →](https://nexus-aissam.github.io/bun-image-turbo/examples/)**
|
|
138
125
|
|
|
139
|
-
|
|
126
|
+
---
|
|
140
127
|
|
|
141
|
-
|
|
128
|
+
## Benchmarks
|
|
142
129
|
|
|
143
|
-
|
|
144
|
-
const info = await metadata(imageBuffer);
|
|
145
|
-
// { width: 1920, height: 1080, format: 'jpeg', hasAlpha: false, ... }
|
|
146
|
-
```
|
|
130
|
+
Tested on Apple M1 Pro with Bun 1.3.3 (compared to sharp v0.34.5):
|
|
147
131
|
|
|
148
|
-
###
|
|
132
|
+
### Metadata Extraction
|
|
149
133
|
|
|
150
|
-
|
|
134
|
+
| Operation | bun-image-turbo | sharp | Speedup |
|
|
135
|
+
|-----------|---------------:|------:|:-------:|
|
|
136
|
+
| WebP Metadata | **0.004ms** | 3.4ms | **950x** |
|
|
137
|
+
| JPEG Metadata | **0.003ms** | 0.1ms | **38x** |
|
|
138
|
+
| PNG Metadata | **0.002ms** | 0.08ms | **40x** |
|
|
151
139
|
|
|
152
|
-
|
|
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
|
-
```
|
|
140
|
+
### Image Processing
|
|
167
141
|
|
|
168
|
-
|
|
142
|
+
| Operation | bun-image-turbo | sharp | Speedup |
|
|
143
|
+
|-----------|---------------:|------:|:-------:|
|
|
144
|
+
| 50 Concurrent Ops | **62ms** | 160ms | **2.6x** |
|
|
145
|
+
| Transform Pipeline | **12.2ms** | 19.1ms | **1.6x** |
|
|
146
|
+
| 1MB JPEG → 800px | **12.6ms** | 20.3ms | **1.6x** |
|
|
147
|
+
| Thumbnail (200px) | **8.8ms** | 10.7ms | **1.2x** |
|
|
169
148
|
|
|
170
|
-
|
|
149
|
+
### HEIC Support (Exclusive)
|
|
171
150
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
151
|
+
| Operation | Time | Notes |
|
|
152
|
+
|-----------|-----:|:------|
|
|
153
|
+
| HEIC Metadata | **0.1ms** | Header-only parsing |
|
|
154
|
+
| HEIC → JPEG | **169ms** | Full quality conversion |
|
|
155
|
+
| HEIC → 800px | **138ms** | Shrink-on-decode |
|
|
156
|
+
| HEIC → Thumbnail | **137ms** | Fast 200px generation |
|
|
175
157
|
|
|
176
|
-
|
|
158
|
+
> **sharp does NOT support HEIC/HEIF files!** bun-image-turbo is the only high-performance library with native HEIC support.
|
|
177
159
|
|
|
178
|
-
|
|
160
|
+
### EXIF Metadata (NEW in v1.3.0)
|
|
179
161
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
162
|
+
| Operation | JPEG | WebP | Notes |
|
|
163
|
+
|-----------|-----:|-----:|:------|
|
|
164
|
+
| writeExif (simple) | **0.24ms** | **0.10ms** | 3 fields |
|
|
165
|
+
| writeExif (full) | **0.20ms** | **0.05ms** | 10 fields + JSON |
|
|
166
|
+
| stripExif | **0.26ms** | **0.08ms** | Remove all metadata |
|
|
183
167
|
|
|
184
|
-
|
|
168
|
+
> **Perfect for AI-generated images!** Store prompts, seeds, and generation parameters in standard EXIF fields.
|
|
185
169
|
|
|
186
|
-
|
|
170
|
+
**[Full benchmark details →](https://nexus-aissam.github.io/bun-image-turbo/guide/performance)**
|
|
187
171
|
|
|
188
|
-
|
|
189
|
-
// Lossy WebP
|
|
190
|
-
const webp = await toWebp(imageBuffer, { quality: 80 });
|
|
172
|
+
---
|
|
191
173
|
|
|
192
|
-
|
|
193
|
-
const lossless = await toWebp(imageBuffer, { lossless: true });
|
|
194
|
-
```
|
|
174
|
+
## Technology Stack
|
|
195
175
|
|
|
196
|
-
|
|
176
|
+
| Component | Technology | Benefit |
|
|
177
|
+
|-----------|------------|---------|
|
|
178
|
+
| **JPEG Codec** | TurboJPEG (libjpeg-turbo) | SIMD acceleration (SSE2/AVX2/NEON) |
|
|
179
|
+
| **Resize Engine** | fast_image_resize + Rayon | Multi-threaded with adaptive algorithms |
|
|
180
|
+
| **WebP Codec** | libwebp bindings | Google's optimized encoder/decoder |
|
|
181
|
+
| **HEIC Decoder** | libheif-rs | Native Apple format support |
|
|
182
|
+
| **Node Bindings** | napi-rs | Zero-copy buffer handling |
|
|
197
183
|
|
|
198
|
-
|
|
184
|
+
**[Architecture deep dive →](https://nexus-aissam.github.io/bun-image-turbo/guide/architecture)**
|
|
199
185
|
|
|
200
|
-
|
|
201
|
-
const result = await transform(imageBuffer, {
|
|
202
|
-
// Resize
|
|
203
|
-
resize: { width: 800, height: 600, fit: 'cover' },
|
|
186
|
+
---
|
|
204
187
|
|
|
205
|
-
|
|
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
|
-
```
|
|
188
|
+
## Features
|
|
222
189
|
|
|
223
|
-
|
|
190
|
+
- **TurboJPEG with SIMD** - 2-6x faster JPEG encoding/decoding via libjpeg-turbo
|
|
191
|
+
- **Shrink-on-Decode** - Decode JPEG/HEIC at reduced resolution for faster thumbnails
|
|
192
|
+
- **Adaptive Algorithms** - Auto-selects optimal resize filter based on scale factor
|
|
193
|
+
- **Native HEIC Support** - The only high-performance library with HEIC/HEIF decoding
|
|
194
|
+
- **EXIF Metadata Writing** - Write/strip EXIF data for AI image attribution
|
|
195
|
+
- **Blurhash Generation** - Built-in compact placeholder generation
|
|
196
|
+
- **Multi-Step Resize** - Progressive halving for large scale reductions
|
|
197
|
+
- **Async & Sync APIs** - Both async and sync versions available
|
|
198
|
+
- **TypeScript First** - Full TypeScript support with strict types
|
|
199
|
+
- **Cross-Platform** - macOS, Linux, Windows support
|
|
224
200
|
|
|
225
|
-
|
|
201
|
+
---
|
|
226
202
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
203
|
+
## API Overview
|
|
204
|
+
|
|
205
|
+
| Function | Description | Docs |
|
|
206
|
+
|----------|-------------|------|
|
|
207
|
+
| `metadata()` | Get image info (ultra-fast) | [→](https://nexus-aissam.github.io/bun-image-turbo/api/metadata) |
|
|
208
|
+
| `resize()` | Resize image (outputs PNG) | [→](https://nexus-aissam.github.io/bun-image-turbo/api/resize) |
|
|
209
|
+
| `transform()` | Multi-operation pipeline | [→](https://nexus-aissam.github.io/bun-image-turbo/api/transform) |
|
|
210
|
+
| `toJpeg()` | Convert to JPEG | [→](https://nexus-aissam.github.io/bun-image-turbo/api/to-jpeg) |
|
|
211
|
+
| `toPng()` | Convert to PNG | [→](https://nexus-aissam.github.io/bun-image-turbo/api/to-png) |
|
|
212
|
+
| `toWebp()` | Convert to WebP | [→](https://nexus-aissam.github.io/bun-image-turbo/api/to-webp) |
|
|
213
|
+
| `blurhash()` | Generate placeholder hash | [→](https://nexus-aissam.github.io/bun-image-turbo/api/blurhash) |
|
|
214
|
+
| `writeExif()` | Write EXIF metadata | [→](https://nexus-aissam.github.io/bun-image-turbo/api/exif) |
|
|
215
|
+
| `stripExif()` | Remove EXIF metadata | [→](https://nexus-aissam.github.io/bun-image-turbo/api/exif) |
|
|
216
|
+
|
|
217
|
+
All functions have sync variants (`metadataSync`, `resizeSync`, `writeExifSync`, etc.)
|
|
218
|
+
|
|
219
|
+
**[Full API Reference →](https://nexus-aissam.github.io/bun-image-turbo/api/)**
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Supported Formats
|
|
224
|
+
|
|
225
|
+
| Format | Read | Write | Notes |
|
|
226
|
+
|--------|:----:|:-----:|-------|
|
|
227
|
+
| JPEG | ✅ | ✅ | TurboJPEG with SIMD |
|
|
228
|
+
| PNG | ✅ | ✅ | Adaptive compression |
|
|
229
|
+
| WebP | ✅ | ✅ | Lossy & lossless |
|
|
230
|
+
| HEIC/HEIF | ✅ | ❌ | macOS ARM64 only |
|
|
231
|
+
| AVIF | ✅ | ❌ | Via libheif |
|
|
232
|
+
| GIF | ✅ | ✅ | Animated support |
|
|
233
|
+
| BMP | ✅ | ✅ | Full support |
|
|
234
|
+
| TIFF | ✅ | ❌ | Multi-page support |
|
|
235
|
+
| ICO | ✅ | ❌ | Multi-size icons |
|
|
236
|
+
|
|
237
|
+
**[Format guide →](https://nexus-aissam.github.io/bun-image-turbo/guide/formats)**
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Platform Support
|
|
242
|
+
|
|
243
|
+
Prebuilt binaries are available for all major platforms:
|
|
244
|
+
|
|
245
|
+
| Platform | Architecture | Supported | HEIC |
|
|
246
|
+
|----------|--------------|:---------:|:----:|
|
|
247
|
+
| macOS | ARM64 (M1/M2/M3/M4/M5) | ✅ | ✅ |
|
|
248
|
+
| macOS | x64 (Intel) | ✅ | ❌ |
|
|
249
|
+
| Linux | x64 (glibc) | ✅ | ❌ |
|
|
250
|
+
| Linux | x64 (musl/Alpine) | ✅ | ❌ |
|
|
251
|
+
| Linux | ARM64 (glibc) | ✅ | ❌ |
|
|
252
|
+
| Windows | x64 | ✅ | ❌ |
|
|
253
|
+
| Windows | ARM64 | ✅ | ❌ |
|
|
254
|
+
|
|
255
|
+
> **Note:** HEIC/HEIF decoding is only available on macOS ARM64. All other formats work on all platforms.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Examples
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
cd examples
|
|
263
|
+
bun install
|
|
264
|
+
|
|
265
|
+
bun run basic # Core functionality
|
|
266
|
+
bun run heic # HEIC conversion (macOS ARM64)
|
|
267
|
+
bun run api # HTTP image server
|
|
268
|
+
bun run batch # Parallel batch processing
|
|
230
269
|
```
|
|
231
270
|
|
|
232
|
-
|
|
271
|
+
| Example | Description |
|
|
272
|
+
|---------|-------------|
|
|
273
|
+
| [basic-usage.ts](./examples/basic-usage.ts) | Metadata, resize, convert, transform |
|
|
274
|
+
| [heic-conversion.ts](./examples/heic-conversion.ts) | iPhone photo conversion |
|
|
275
|
+
| [api-endpoint.ts](./examples/api-endpoint.ts) | HTTP image processing server |
|
|
276
|
+
| [batch-processing.ts](./examples/batch-processing.ts) | Parallel multi-file processing |
|
|
233
277
|
|
|
234
|
-
|
|
278
|
+
### EXIF Metadata Example
|
|
235
279
|
|
|
236
280
|
```typescript
|
|
237
|
-
|
|
281
|
+
import { writeExif, toWebp, stripExif } from 'bun-image-turbo';
|
|
282
|
+
|
|
283
|
+
// Add AI generation metadata to WebP
|
|
284
|
+
const webp = await toWebp(imageBuffer, { quality: 90 });
|
|
285
|
+
const withMetadata = await writeExif(webp, {
|
|
286
|
+
imageDescription: 'A sunset over mountains',
|
|
287
|
+
artist: 'Stable Diffusion XL',
|
|
288
|
+
software: 'ComfyUI',
|
|
289
|
+
userComment: JSON.stringify({
|
|
290
|
+
prompt: 'sunset over mountains, 8k',
|
|
291
|
+
seed: 12345,
|
|
292
|
+
steps: 30,
|
|
293
|
+
cfg_scale: 7.5
|
|
294
|
+
})
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// Strip metadata for privacy
|
|
298
|
+
const clean = await stripExif(photoWithGPS);
|
|
238
299
|
```
|
|
239
300
|
|
|
240
|
-
|
|
301
|
+
**[All examples →](https://nexus-aissam.github.io/bun-image-turbo/examples/)**
|
|
241
302
|
|
|
242
|
-
|
|
303
|
+
---
|
|
243
304
|
|
|
244
|
-
|
|
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 |
|
|
305
|
+
## Documentation
|
|
250
306
|
|
|
251
|
-
|
|
307
|
+
<table>
|
|
308
|
+
<tr>
|
|
309
|
+
<td width="50%">
|
|
252
310
|
|
|
253
|
-
|
|
254
|
-
- `bilinear` - Fast, good quality
|
|
255
|
-
- `catmullRom` - Balanced speed and quality
|
|
256
|
-
- `mitchell` - Good for downscaling
|
|
257
|
-
- `lanczos3` - Highest quality, slower (default)
|
|
311
|
+
### Online Documentation
|
|
258
312
|
|
|
259
|
-
|
|
313
|
+
Full documentation with examples, API reference, and guides:
|
|
260
314
|
|
|
261
|
-
-
|
|
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
|
|
315
|
+
**[nexus-aissam.github.io/bun-image-turbo](https://nexus-aissam.github.io/bun-image-turbo/)**
|
|
266
316
|
|
|
267
|
-
|
|
317
|
+
- [Getting Started](https://nexus-aissam.github.io/bun-image-turbo/guide/)
|
|
318
|
+
- [API Reference](https://nexus-aissam.github.io/bun-image-turbo/api/)
|
|
319
|
+
- [Examples](https://nexus-aissam.github.io/bun-image-turbo/examples/)
|
|
320
|
+
- [Architecture](https://nexus-aissam.github.io/bun-image-turbo/guide/architecture)
|
|
321
|
+
- [Performance](https://nexus-aissam.github.io/bun-image-turbo/guide/performance)
|
|
268
322
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
| `quality` | `number` | `80` | Quality 1-100 |
|
|
323
|
+
</td>
|
|
324
|
+
<td width="50%">
|
|
272
325
|
|
|
273
|
-
###
|
|
326
|
+
### Offline Documentation
|
|
274
327
|
|
|
275
|
-
|
|
276
|
-
|--------|------|---------|-------------|
|
|
277
|
-
| `compression` | `number` | `6` | Compression level 0-9 |
|
|
328
|
+
Documentation is also available in the [`docs/`](./docs/) folder:
|
|
278
329
|
|
|
279
|
-
|
|
330
|
+
- [Guide](./docs/guide/)
|
|
331
|
+
- [API](./docs/api/)
|
|
332
|
+
- [Examples](./docs/examples/)
|
|
280
333
|
|
|
281
|
-
|
|
282
|
-
|--------|------|---------|-------------|
|
|
283
|
-
| `quality` | `number` | `80` | Quality 1-100 (lossy) |
|
|
284
|
-
| `lossless` | `boolean` | `false` | Use lossless compression |
|
|
334
|
+
View locally:
|
|
285
335
|
|
|
286
|
-
|
|
336
|
+
```bash
|
|
337
|
+
cd docs
|
|
338
|
+
bun install
|
|
339
|
+
bun run docs:dev
|
|
340
|
+
```
|
|
287
341
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
|
342
|
+
</td>
|
|
343
|
+
</tr>
|
|
344
|
+
</table>
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Contributing
|
|
313
349
|
|
|
314
350
|
```bash
|
|
315
|
-
# Clone
|
|
351
|
+
# Clone
|
|
316
352
|
git clone https://github.com/nexus-aissam/bun-image-turbo.git
|
|
317
353
|
cd bun-image-turbo
|
|
318
354
|
|
|
319
355
|
# Install dependencies
|
|
320
356
|
bun install
|
|
321
357
|
|
|
322
|
-
# Build native module (requires Rust)
|
|
358
|
+
# Build native module (requires Rust 1.70+)
|
|
323
359
|
bun run build
|
|
324
360
|
|
|
325
361
|
# Build TypeScript
|
|
326
362
|
bun run build:ts
|
|
327
363
|
|
|
328
364
|
# Run tests
|
|
329
|
-
bun test
|
|
365
|
+
bun test test/
|
|
330
366
|
```
|
|
331
367
|
|
|
332
368
|
### Requirements
|
|
@@ -334,20 +370,36 @@ bun test
|
|
|
334
370
|
- Bun 1.0+ or Node.js 18+
|
|
335
371
|
- Rust 1.70+ (for building from source)
|
|
336
372
|
|
|
373
|
+
---
|
|
374
|
+
|
|
337
375
|
## License
|
|
338
376
|
|
|
339
377
|
MIT License - see [LICENSE](LICENSE) for details.
|
|
340
378
|
|
|
379
|
+
---
|
|
380
|
+
|
|
341
381
|
## Author
|
|
342
382
|
|
|
343
|
-
Aissam Irhir ([@nexus-aissam](https://github.com/nexus-aissam))
|
|
383
|
+
**Aissam Irhir** ([@nexus-aissam](https://github.com/nexus-aissam))
|
|
384
|
+
|
|
385
|
+
---
|
|
344
386
|
|
|
345
387
|
## Acknowledgments
|
|
346
388
|
|
|
347
389
|
- [turbojpeg](https://crates.io/crates/turbojpeg) - libjpeg-turbo bindings with SIMD
|
|
348
390
|
- [image](https://crates.io/crates/image) - Rust image processing library
|
|
349
|
-
- [fast_image_resize](https://crates.io/crates/fast_image_resize) - Fast image resizing
|
|
391
|
+
- [fast_image_resize](https://crates.io/crates/fast_image_resize) - Fast image resizing with Rayon
|
|
350
392
|
- [webp](https://crates.io/crates/webp) - WebP encoding/decoding
|
|
351
393
|
- [libheif-rs](https://crates.io/crates/libheif-rs) - HEIC/HEIF decoding via libheif
|
|
394
|
+
- [img-parts](https://crates.io/crates/img-parts) - EXIF/XMP metadata manipulation
|
|
352
395
|
- [blurhash](https://crates.io/crates/blurhash) - Blurhash generation
|
|
353
396
|
- [napi-rs](https://napi.rs/) - Rust bindings for Node.js
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
<p align="center">
|
|
401
|
+
<a href="https://nexus-aissam.github.io/bun-image-turbo/">Documentation</a> •
|
|
402
|
+
<a href="https://nexus-aissam.github.io/bun-image-turbo/api/">API</a> •
|
|
403
|
+
<a href="https://www.npmjs.com/package/bun-image-turbo">npm</a> •
|
|
404
|
+
<a href="https://github.com/nexus-aissam/bun-image-turbo">GitHub</a>
|
|
405
|
+
</p>
|
package/dist/index.d.mts
CHANGED
|
@@ -107,6 +107,29 @@ interface BlurHashResult {
|
|
|
107
107
|
/** Original height */
|
|
108
108
|
height: number;
|
|
109
109
|
}
|
|
110
|
+
/** EXIF metadata options for writing */
|
|
111
|
+
interface ExifOptions {
|
|
112
|
+
/** Image description / caption / AI prompt */
|
|
113
|
+
imageDescription?: string;
|
|
114
|
+
/** Artist / creator name */
|
|
115
|
+
artist?: string;
|
|
116
|
+
/** Copyright notice */
|
|
117
|
+
copyright?: string;
|
|
118
|
+
/** Software used to create the image */
|
|
119
|
+
software?: string;
|
|
120
|
+
/** Date/time in EXIF format (YYYY:MM:DD HH:MM:SS) */
|
|
121
|
+
dateTime?: string;
|
|
122
|
+
/** Original date/time in EXIF format */
|
|
123
|
+
dateTimeOriginal?: string;
|
|
124
|
+
/** User comment (can contain JSON or other data) */
|
|
125
|
+
userComment?: string;
|
|
126
|
+
/** Camera/device make */
|
|
127
|
+
make?: string;
|
|
128
|
+
/** Camera/device model */
|
|
129
|
+
model?: string;
|
|
130
|
+
/** Orientation (1-8) */
|
|
131
|
+
orientation?: number;
|
|
132
|
+
}
|
|
110
133
|
/** Transform options (all-in-one processing) */
|
|
111
134
|
interface TransformOptions {
|
|
112
135
|
/** Resize options */
|
|
@@ -129,6 +152,8 @@ interface TransformOptions {
|
|
|
129
152
|
brightness?: number;
|
|
130
153
|
/** Contrast adjustment (-100 to 100) */
|
|
131
154
|
contrast?: number;
|
|
155
|
+
/** EXIF metadata to write (for JPEG/WebP output) */
|
|
156
|
+
exif?: ExifOptions;
|
|
132
157
|
}
|
|
133
158
|
|
|
134
159
|
/**
|
|
@@ -302,6 +327,52 @@ declare function transformSync(input: Buffer, options: TransformOptions): Buffer
|
|
|
302
327
|
* Generate blurhash from image synchronously
|
|
303
328
|
*/
|
|
304
329
|
declare function blurhashSync(input: Buffer, componentsX?: number, componentsY?: number): BlurHashResult;
|
|
330
|
+
/**
|
|
331
|
+
* Write EXIF metadata to an image asynchronously
|
|
332
|
+
*
|
|
333
|
+
* Supports JPEG and WebP formats.
|
|
334
|
+
*
|
|
335
|
+
* @param input - Image buffer
|
|
336
|
+
* @param options - EXIF metadata options
|
|
337
|
+
* @returns Promise resolving to image buffer with EXIF data
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```typescript
|
|
341
|
+
* const withExif = await writeExif(imageBuffer, {
|
|
342
|
+
* imageDescription: 'A beautiful sunset over the ocean',
|
|
343
|
+
* artist: 'John Doe',
|
|
344
|
+
* software: 'My AI App v1.0',
|
|
345
|
+
* userComment: JSON.stringify({ model: 'stable-diffusion', seed: 12345 })
|
|
346
|
+
* });
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare function writeExif(input: Buffer, options: ExifOptions): Promise<Buffer>;
|
|
350
|
+
/**
|
|
351
|
+
* Write EXIF metadata to an image synchronously
|
|
352
|
+
*
|
|
353
|
+
* Supports JPEG and WebP formats.
|
|
354
|
+
*/
|
|
355
|
+
declare function writeExifSync(input: Buffer, options: ExifOptions): Buffer;
|
|
356
|
+
/**
|
|
357
|
+
* Strip all EXIF metadata from an image asynchronously
|
|
358
|
+
*
|
|
359
|
+
* Supports JPEG and WebP formats.
|
|
360
|
+
*
|
|
361
|
+
* @param input - Image buffer
|
|
362
|
+
* @returns Promise resolving to image buffer without EXIF data
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* ```typescript
|
|
366
|
+
* const stripped = await stripExif(imageBuffer);
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
declare function stripExif(input: Buffer): Promise<Buffer>;
|
|
370
|
+
/**
|
|
371
|
+
* Strip all EXIF metadata from an image synchronously
|
|
372
|
+
*
|
|
373
|
+
* Supports JPEG and WebP formats.
|
|
374
|
+
*/
|
|
375
|
+
declare function stripExifSync(input: Buffer): Buffer;
|
|
305
376
|
/**
|
|
306
377
|
* Get library version
|
|
307
378
|
*/
|
|
@@ -321,7 +392,11 @@ declare const _default: {
|
|
|
321
392
|
transformSync: typeof transformSync;
|
|
322
393
|
blurhash: typeof blurhash;
|
|
323
394
|
blurhashSync: typeof blurhashSync;
|
|
395
|
+
writeExif: typeof writeExif;
|
|
396
|
+
writeExifSync: typeof writeExifSync;
|
|
397
|
+
stripExif: typeof stripExif;
|
|
398
|
+
stripExifSync: typeof stripExifSync;
|
|
324
399
|
version: typeof version;
|
|
325
400
|
};
|
|
326
401
|
|
|
327
|
-
export { type AvifOptions, type BlurHashResult, type FitMode, type ImageFormat, type ImageMetadata, type JpegOptions, type OutputOptions, type PngOptions, type ResizeFilter, type ResizeOptions, type TransformOptions, type WebPOptions, blurhash, blurhashSync, _default as default, metadata, metadataSync, resize, resizeSync, toJpeg, toJpegSync, toPng, toPngSync, toWebp, toWebpSync, transform, transformSync, version };
|
|
402
|
+
export { type AvifOptions, type BlurHashResult, type ExifOptions, type FitMode, type ImageFormat, type ImageMetadata, type JpegOptions, type OutputOptions, type PngOptions, type ResizeFilter, type ResizeOptions, type TransformOptions, type WebPOptions, blurhash, blurhashSync, _default as default, metadata, metadataSync, resize, resizeSync, stripExif, stripExifSync, toJpeg, toJpegSync, toPng, toPngSync, toWebp, toWebpSync, transform, transformSync, version, writeExif, writeExifSync };
|
package/dist/index.d.ts
CHANGED
|
@@ -107,6 +107,29 @@ interface BlurHashResult {
|
|
|
107
107
|
/** Original height */
|
|
108
108
|
height: number;
|
|
109
109
|
}
|
|
110
|
+
/** EXIF metadata options for writing */
|
|
111
|
+
interface ExifOptions {
|
|
112
|
+
/** Image description / caption / AI prompt */
|
|
113
|
+
imageDescription?: string;
|
|
114
|
+
/** Artist / creator name */
|
|
115
|
+
artist?: string;
|
|
116
|
+
/** Copyright notice */
|
|
117
|
+
copyright?: string;
|
|
118
|
+
/** Software used to create the image */
|
|
119
|
+
software?: string;
|
|
120
|
+
/** Date/time in EXIF format (YYYY:MM:DD HH:MM:SS) */
|
|
121
|
+
dateTime?: string;
|
|
122
|
+
/** Original date/time in EXIF format */
|
|
123
|
+
dateTimeOriginal?: string;
|
|
124
|
+
/** User comment (can contain JSON or other data) */
|
|
125
|
+
userComment?: string;
|
|
126
|
+
/** Camera/device make */
|
|
127
|
+
make?: string;
|
|
128
|
+
/** Camera/device model */
|
|
129
|
+
model?: string;
|
|
130
|
+
/** Orientation (1-8) */
|
|
131
|
+
orientation?: number;
|
|
132
|
+
}
|
|
110
133
|
/** Transform options (all-in-one processing) */
|
|
111
134
|
interface TransformOptions {
|
|
112
135
|
/** Resize options */
|
|
@@ -129,6 +152,8 @@ interface TransformOptions {
|
|
|
129
152
|
brightness?: number;
|
|
130
153
|
/** Contrast adjustment (-100 to 100) */
|
|
131
154
|
contrast?: number;
|
|
155
|
+
/** EXIF metadata to write (for JPEG/WebP output) */
|
|
156
|
+
exif?: ExifOptions;
|
|
132
157
|
}
|
|
133
158
|
|
|
134
159
|
/**
|
|
@@ -302,6 +327,52 @@ declare function transformSync(input: Buffer, options: TransformOptions): Buffer
|
|
|
302
327
|
* Generate blurhash from image synchronously
|
|
303
328
|
*/
|
|
304
329
|
declare function blurhashSync(input: Buffer, componentsX?: number, componentsY?: number): BlurHashResult;
|
|
330
|
+
/**
|
|
331
|
+
* Write EXIF metadata to an image asynchronously
|
|
332
|
+
*
|
|
333
|
+
* Supports JPEG and WebP formats.
|
|
334
|
+
*
|
|
335
|
+
* @param input - Image buffer
|
|
336
|
+
* @param options - EXIF metadata options
|
|
337
|
+
* @returns Promise resolving to image buffer with EXIF data
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```typescript
|
|
341
|
+
* const withExif = await writeExif(imageBuffer, {
|
|
342
|
+
* imageDescription: 'A beautiful sunset over the ocean',
|
|
343
|
+
* artist: 'John Doe',
|
|
344
|
+
* software: 'My AI App v1.0',
|
|
345
|
+
* userComment: JSON.stringify({ model: 'stable-diffusion', seed: 12345 })
|
|
346
|
+
* });
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare function writeExif(input: Buffer, options: ExifOptions): Promise<Buffer>;
|
|
350
|
+
/**
|
|
351
|
+
* Write EXIF metadata to an image synchronously
|
|
352
|
+
*
|
|
353
|
+
* Supports JPEG and WebP formats.
|
|
354
|
+
*/
|
|
355
|
+
declare function writeExifSync(input: Buffer, options: ExifOptions): Buffer;
|
|
356
|
+
/**
|
|
357
|
+
* Strip all EXIF metadata from an image asynchronously
|
|
358
|
+
*
|
|
359
|
+
* Supports JPEG and WebP formats.
|
|
360
|
+
*
|
|
361
|
+
* @param input - Image buffer
|
|
362
|
+
* @returns Promise resolving to image buffer without EXIF data
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* ```typescript
|
|
366
|
+
* const stripped = await stripExif(imageBuffer);
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
declare function stripExif(input: Buffer): Promise<Buffer>;
|
|
370
|
+
/**
|
|
371
|
+
* Strip all EXIF metadata from an image synchronously
|
|
372
|
+
*
|
|
373
|
+
* Supports JPEG and WebP formats.
|
|
374
|
+
*/
|
|
375
|
+
declare function stripExifSync(input: Buffer): Buffer;
|
|
305
376
|
/**
|
|
306
377
|
* Get library version
|
|
307
378
|
*/
|
|
@@ -321,7 +392,11 @@ declare const _default: {
|
|
|
321
392
|
transformSync: typeof transformSync;
|
|
322
393
|
blurhash: typeof blurhash;
|
|
323
394
|
blurhashSync: typeof blurhashSync;
|
|
395
|
+
writeExif: typeof writeExif;
|
|
396
|
+
writeExifSync: typeof writeExifSync;
|
|
397
|
+
stripExif: typeof stripExif;
|
|
398
|
+
stripExifSync: typeof stripExifSync;
|
|
324
399
|
version: typeof version;
|
|
325
400
|
};
|
|
326
401
|
|
|
327
|
-
export { type AvifOptions, type BlurHashResult, type FitMode, type ImageFormat, type ImageMetadata, type JpegOptions, type OutputOptions, type PngOptions, type ResizeFilter, type ResizeOptions, type TransformOptions, type WebPOptions, blurhash, blurhashSync, _default as default, metadata, metadataSync, resize, resizeSync, toJpeg, toJpegSync, toPng, toPngSync, toWebp, toWebpSync, transform, transformSync, version };
|
|
402
|
+
export { type AvifOptions, type BlurHashResult, type ExifOptions, type FitMode, type ImageFormat, type ImageMetadata, type JpegOptions, type OutputOptions, type PngOptions, type ResizeFilter, type ResizeOptions, type TransformOptions, type WebPOptions, blurhash, blurhashSync, _default as default, metadata, metadataSync, resize, resizeSync, stripExif, stripExifSync, toJpeg, toJpegSync, toPng, toPngSync, toWebp, toWebpSync, transform, transformSync, version, writeExif, writeExifSync };
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,8 @@ __export(index_exports, {
|
|
|
27
27
|
metadataSync: () => metadataSync,
|
|
28
28
|
resize: () => resize,
|
|
29
29
|
resizeSync: () => resizeSync,
|
|
30
|
+
stripExif: () => stripExif,
|
|
31
|
+
stripExifSync: () => stripExifSync,
|
|
30
32
|
toJpeg: () => toJpeg,
|
|
31
33
|
toJpegSync: () => toJpegSync,
|
|
32
34
|
toPng: () => toPng,
|
|
@@ -35,7 +37,9 @@ __export(index_exports, {
|
|
|
35
37
|
toWebpSync: () => toWebpSync,
|
|
36
38
|
transform: () => transform,
|
|
37
39
|
transformSync: () => transformSync,
|
|
38
|
-
version: () => version
|
|
40
|
+
version: () => version,
|
|
41
|
+
writeExif: () => writeExif,
|
|
42
|
+
writeExifSync: () => writeExifSync
|
|
39
43
|
});
|
|
40
44
|
module.exports = __toCommonJS(index_exports);
|
|
41
45
|
var import_fs = require("fs");
|
|
@@ -154,6 +158,9 @@ function toNapiTransformOptions(options) {
|
|
|
154
158
|
result.sharpen = options.sharpen;
|
|
155
159
|
result.brightness = options.brightness;
|
|
156
160
|
result.contrast = options.contrast;
|
|
161
|
+
if (options.exif) {
|
|
162
|
+
result.exif = options.exif;
|
|
163
|
+
}
|
|
157
164
|
return result;
|
|
158
165
|
}
|
|
159
166
|
async function metadata(input) {
|
|
@@ -198,6 +205,18 @@ function transformSync(input, options) {
|
|
|
198
205
|
function blurhashSync(input, componentsX, componentsY) {
|
|
199
206
|
return native.blurhashSync(input, componentsX, componentsY);
|
|
200
207
|
}
|
|
208
|
+
async function writeExif(input, options) {
|
|
209
|
+
return native.writeExif(input, options);
|
|
210
|
+
}
|
|
211
|
+
function writeExifSync(input, options) {
|
|
212
|
+
return native.writeExifSync(input, options);
|
|
213
|
+
}
|
|
214
|
+
async function stripExif(input) {
|
|
215
|
+
return native.stripExif(input);
|
|
216
|
+
}
|
|
217
|
+
function stripExifSync(input) {
|
|
218
|
+
return native.stripExifSync(input);
|
|
219
|
+
}
|
|
201
220
|
function version() {
|
|
202
221
|
return native.version();
|
|
203
222
|
}
|
|
@@ -216,6 +235,10 @@ var index_default = {
|
|
|
216
235
|
transformSync,
|
|
217
236
|
blurhash,
|
|
218
237
|
blurhashSync,
|
|
238
|
+
writeExif,
|
|
239
|
+
writeExifSync,
|
|
240
|
+
stripExif,
|
|
241
|
+
stripExifSync,
|
|
219
242
|
version
|
|
220
243
|
};
|
|
221
244
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -226,6 +249,8 @@ var index_default = {
|
|
|
226
249
|
metadataSync,
|
|
227
250
|
resize,
|
|
228
251
|
resizeSync,
|
|
252
|
+
stripExif,
|
|
253
|
+
stripExifSync,
|
|
229
254
|
toJpeg,
|
|
230
255
|
toJpegSync,
|
|
231
256
|
toPng,
|
|
@@ -234,5 +259,7 @@ var index_default = {
|
|
|
234
259
|
toWebpSync,
|
|
235
260
|
transform,
|
|
236
261
|
transformSync,
|
|
237
|
-
version
|
|
262
|
+
version,
|
|
263
|
+
writeExif,
|
|
264
|
+
writeExifSync
|
|
238
265
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -121,6 +121,9 @@ function toNapiTransformOptions(options) {
|
|
|
121
121
|
result.sharpen = options.sharpen;
|
|
122
122
|
result.brightness = options.brightness;
|
|
123
123
|
result.contrast = options.contrast;
|
|
124
|
+
if (options.exif) {
|
|
125
|
+
result.exif = options.exif;
|
|
126
|
+
}
|
|
124
127
|
return result;
|
|
125
128
|
}
|
|
126
129
|
async function metadata(input) {
|
|
@@ -165,6 +168,18 @@ function transformSync(input, options) {
|
|
|
165
168
|
function blurhashSync(input, componentsX, componentsY) {
|
|
166
169
|
return native.blurhashSync(input, componentsX, componentsY);
|
|
167
170
|
}
|
|
171
|
+
async function writeExif(input, options) {
|
|
172
|
+
return native.writeExif(input, options);
|
|
173
|
+
}
|
|
174
|
+
function writeExifSync(input, options) {
|
|
175
|
+
return native.writeExifSync(input, options);
|
|
176
|
+
}
|
|
177
|
+
async function stripExif(input) {
|
|
178
|
+
return native.stripExif(input);
|
|
179
|
+
}
|
|
180
|
+
function stripExifSync(input) {
|
|
181
|
+
return native.stripExifSync(input);
|
|
182
|
+
}
|
|
168
183
|
function version() {
|
|
169
184
|
return native.version();
|
|
170
185
|
}
|
|
@@ -183,6 +198,10 @@ var index_default = {
|
|
|
183
198
|
transformSync,
|
|
184
199
|
blurhash,
|
|
185
200
|
blurhashSync,
|
|
201
|
+
writeExif,
|
|
202
|
+
writeExifSync,
|
|
203
|
+
stripExif,
|
|
204
|
+
stripExifSync,
|
|
186
205
|
version
|
|
187
206
|
};
|
|
188
207
|
export {
|
|
@@ -193,6 +212,8 @@ export {
|
|
|
193
212
|
metadataSync,
|
|
194
213
|
resize,
|
|
195
214
|
resizeSync,
|
|
215
|
+
stripExif,
|
|
216
|
+
stripExifSync,
|
|
196
217
|
toJpeg,
|
|
197
218
|
toJpegSync,
|
|
198
219
|
toPng,
|
|
@@ -201,5 +222,7 @@ export {
|
|
|
201
222
|
toWebpSync,
|
|
202
223
|
transform,
|
|
203
224
|
transformSync,
|
|
204
|
-
version
|
|
225
|
+
version,
|
|
226
|
+
writeExif,
|
|
227
|
+
writeExifSync
|
|
205
228
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-image-turbo",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.3.0",
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
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.
|
|
96
|
-
"bun-image-turbo-darwin-x64": "1.
|
|
97
|
-
"bun-image-turbo-linux-arm64-gnu": "1.
|
|
98
|
-
"bun-image-turbo-linux-x64-gnu": "1.
|
|
99
|
-
"bun-image-turbo-linux-x64-musl": "1.
|
|
100
|
-
"bun-image-turbo-win32-arm64-msvc": "1.
|
|
101
|
-
"bun-image-turbo-win32-x64-msvc": "1.
|
|
95
|
+
"bun-image-turbo-darwin-arm64": "1.3.0",
|
|
96
|
+
"bun-image-turbo-darwin-x64": "1.3.0",
|
|
97
|
+
"bun-image-turbo-linux-arm64-gnu": "1.3.0",
|
|
98
|
+
"bun-image-turbo-linux-x64-gnu": "1.3.0",
|
|
99
|
+
"bun-image-turbo-linux-x64-musl": "1.3.0",
|
|
100
|
+
"bun-image-turbo-win32-arm64-msvc": "1.3.0",
|
|
101
|
+
"bun-image-turbo-win32-x64-msvc": "1.3.0"
|
|
102
102
|
}
|
|
103
103
|
}
|