bun-image-turbo 1.3.0 → 1.4.5

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
@@ -34,6 +34,7 @@
34
34
  |----------|:-------:|-----|
35
35
  | WebP Metadata | **950x** | Header-only parsing, no decode |
36
36
  | JPEG Metadata | **38x** | Optimized marker extraction |
37
+ | WebP Resize | **1.25x** | Shrink-on-load optimization (NEW in v1.4.0) |
37
38
  | 50 Concurrent Ops | **2.6x** | Rayon thread pool |
38
39
  | Transform Pipeline | **1.6x** | Single-pass processing |
39
40
  | EXIF Write | **<0.3ms** | Native EXIF embedding |
@@ -146,6 +147,18 @@ Tested on Apple M1 Pro with Bun 1.3.3 (compared to sharp v0.34.5):
146
147
  | 1MB JPEG → 800px | **12.6ms** | 20.3ms | **1.6x** |
147
148
  | Thumbnail (200px) | **8.8ms** | 10.7ms | **1.2x** |
148
149
 
150
+ ### WebP Resize (NEW in v1.4.0)
151
+
152
+ | Source Size | Target | bun-image-turbo | sharp | Speedup |
153
+ |-------------|--------|---------------:|------:|:-------:|
154
+ | 800x600 | 200px | **3.1ms** | 4.3ms | **1.40x** |
155
+ | 1600x1200 | 200px | **6.4ms** | 8.0ms | **1.24x** |
156
+ | 2000x1500 | 200px | **8.6ms** | 10.1ms | **1.18x** |
157
+ | 3000x2000 | 200px | **14.7ms** | 16.1ms | **1.10x** |
158
+ | 4000x3000 | 400px | **32.4ms** | 33.1ms | **1.02x** |
159
+
160
+ > **v1.4.0** introduces WebP shrink-on-load optimization using libwebp's native scaling, making WebP resize operations **1.02-1.40x faster** than sharp across all sizes.
161
+
149
162
  ### HEIC Support (Exclusive)
150
163
 
151
164
  | Operation | Time | Notes |
@@ -188,12 +201,14 @@ Tested on Apple M1 Pro with Bun 1.3.3 (compared to sharp v0.34.5):
188
201
  ## Features
189
202
 
190
203
  - **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
204
+ - **Shrink-on-Decode** - Decode JPEG/WebP/HEIC at reduced resolution for faster thumbnails
205
+ - **WebP Shrink-on-Load** - NEW in v1.4.0: Native libwebp scaling for 1.25x faster WebP resize
192
206
  - **Adaptive Algorithms** - Auto-selects optimal resize filter based on scale factor
193
207
  - **Native HEIC Support** - The only high-performance library with HEIC/HEIF decoding
194
208
  - **EXIF Metadata Writing** - Write/strip EXIF data for AI image attribution
195
209
  - **Blurhash Generation** - Built-in compact placeholder generation
196
210
  - **Multi-Step Resize** - Progressive halving for large scale reductions
211
+ - **Zero-Copy Optimizations** - Minimal memory copies for lower memory usage
197
212
  - **Async & Sync APIs** - Both async and sync versions available
198
213
  - **TypeScript First** - Full TypeScript support with strict types
199
214
  - **Cross-Platform** - macOS, Linux, Windows support
package/dist/index.d.mts CHANGED
@@ -157,28 +157,7 @@ interface TransformOptions {
157
157
  }
158
158
 
159
159
  /**
160
- * bun-image-turbo - High-performance image processing for Bun and Node.js
161
- *
162
- * @module bun-image-turbo
163
- * @author Aissam Irhir <aissamirhir@gmail.com>
164
- *
165
- * @example
166
- * ```typescript
167
- * import { resize, toWebp, metadata } from 'bun-image-turbo';
168
- *
169
- * // Read image
170
- * const input = await Bun.file('input.jpg').arrayBuffer();
171
- *
172
- * // Resize image
173
- * const resized = await resize(Buffer.from(input), { width: 800, height: 600 });
174
- *
175
- * // Convert to WebP
176
- * const webp = await toWebp(Buffer.from(input), { quality: 85 });
177
- *
178
- * // Get metadata
179
- * const info = await metadata(Buffer.from(input));
180
- * console.log(info.width, info.height, info.format);
181
- * ```
160
+ * Metadata API functions
182
161
  */
183
162
 
184
163
  /**
@@ -194,6 +173,15 @@ interface TransformOptions {
194
173
  * ```
195
174
  */
196
175
  declare function metadata(input: Buffer): Promise<ImageMetadata>;
176
+ /**
177
+ * Get image metadata synchronously
178
+ */
179
+ declare function metadataSync(input: Buffer): ImageMetadata;
180
+
181
+ /**
182
+ * Resize API functions
183
+ */
184
+
197
185
  /**
198
186
  * Resize image asynchronously
199
187
  *
@@ -218,6 +206,15 @@ declare function metadata(input: Buffer): Promise<ImageMetadata>;
218
206
  * ```
219
207
  */
220
208
  declare function resize(input: Buffer, options: ResizeOptions): Promise<Buffer>;
209
+ /**
210
+ * Resize image synchronously
211
+ */
212
+ declare function resizeSync(input: Buffer, options: ResizeOptions): Buffer;
213
+
214
+ /**
215
+ * Image encoding/format conversion API functions
216
+ */
217
+
221
218
  /**
222
219
  * Convert image to JPEG asynchronously
223
220
  *
@@ -231,6 +228,10 @@ declare function resize(input: Buffer, options: ResizeOptions): Promise<Buffer>;
231
228
  * ```
232
229
  */
233
230
  declare function toJpeg(input: Buffer, options?: JpegOptions): Promise<Buffer>;
231
+ /**
232
+ * Convert image to JPEG synchronously
233
+ */
234
+ declare function toJpegSync(input: Buffer, options?: JpegOptions): Buffer;
234
235
  /**
235
236
  * Convert image to PNG asynchronously
236
237
  *
@@ -244,6 +245,10 @@ declare function toJpeg(input: Buffer, options?: JpegOptions): Promise<Buffer>;
244
245
  * ```
245
246
  */
246
247
  declare function toPng(input: Buffer, options?: PngOptions): Promise<Buffer>;
248
+ /**
249
+ * Convert image to PNG synchronously
250
+ */
251
+ declare function toPngSync(input: Buffer, options?: PngOptions): Buffer;
247
252
  /**
248
253
  * Convert image to WebP asynchronously
249
254
  *
@@ -261,6 +266,15 @@ declare function toPng(input: Buffer, options?: PngOptions): Promise<Buffer>;
261
266
  * ```
262
267
  */
263
268
  declare function toWebp(input: Buffer, options?: WebPOptions): Promise<Buffer>;
269
+ /**
270
+ * Convert image to WebP synchronously
271
+ */
272
+ declare function toWebpSync(input: Buffer, options?: WebPOptions): Buffer;
273
+
274
+ /**
275
+ * Transform API functions
276
+ */
277
+
264
278
  /**
265
279
  * Transform image with multiple operations asynchronously
266
280
  *
@@ -282,6 +296,15 @@ declare function toWebp(input: Buffer, options?: WebPOptions): Promise<Buffer>;
282
296
  * ```
283
297
  */
284
298
  declare function transform(input: Buffer, options: TransformOptions): Promise<Buffer>;
299
+ /**
300
+ * Transform image with multiple operations synchronously
301
+ */
302
+ declare function transformSync(input: Buffer, options: TransformOptions): Buffer;
303
+
304
+ /**
305
+ * Blurhash API functions
306
+ */
307
+
285
308
  /**
286
309
  * Generate blurhash from image asynchronously
287
310
  *
@@ -299,34 +322,15 @@ declare function transform(input: Buffer, options: TransformOptions): Promise<Bu
299
322
  * ```
300
323
  */
301
324
  declare function blurhash(input: Buffer, componentsX?: number, componentsY?: number): Promise<BlurHashResult>;
302
- /**
303
- * Get image metadata synchronously
304
- */
305
- declare function metadataSync(input: Buffer): ImageMetadata;
306
- /**
307
- * Resize image synchronously
308
- */
309
- declare function resizeSync(input: Buffer, options: ResizeOptions): Buffer;
310
- /**
311
- * Convert image to JPEG synchronously
312
- */
313
- declare function toJpegSync(input: Buffer, options?: JpegOptions): Buffer;
314
- /**
315
- * Convert image to PNG synchronously
316
- */
317
- declare function toPngSync(input: Buffer, options?: PngOptions): Buffer;
318
- /**
319
- * Convert image to WebP synchronously
320
- */
321
- declare function toWebpSync(input: Buffer, options?: WebPOptions): Buffer;
322
- /**
323
- * Transform image with multiple operations synchronously
324
- */
325
- declare function transformSync(input: Buffer, options: TransformOptions): Buffer;
326
325
  /**
327
326
  * Generate blurhash from image synchronously
328
327
  */
329
328
  declare function blurhashSync(input: Buffer, componentsX?: number, componentsY?: number): BlurHashResult;
329
+
330
+ /**
331
+ * EXIF metadata API functions
332
+ */
333
+
330
334
  /**
331
335
  * Write EXIF metadata to an image asynchronously
332
336
  *
@@ -373,10 +377,37 @@ declare function stripExif(input: Buffer): Promise<Buffer>;
373
377
  * Supports JPEG and WebP formats.
374
378
  */
375
379
  declare function stripExifSync(input: Buffer): Buffer;
380
+
381
+ /**
382
+ * bun-image-turbo - High-performance image processing for Bun and Node.js
383
+ *
384
+ * @module bun-image-turbo
385
+ * @author Aissam Irhir <aissamirhir@gmail.com>
386
+ *
387
+ * @example
388
+ * ```typescript
389
+ * import { resize, toWebp, metadata } from 'bun-image-turbo';
390
+ *
391
+ * // Read image
392
+ * const input = await Bun.file('input.jpg').arrayBuffer();
393
+ *
394
+ * // Resize image
395
+ * const resized = await resize(Buffer.from(input), { width: 800, height: 600 });
396
+ *
397
+ * // Convert to WebP
398
+ * const webp = await toWebp(Buffer.from(input), { quality: 85 });
399
+ *
400
+ * // Get metadata
401
+ * const info = await metadata(Buffer.from(input));
402
+ * console.log(info.width, info.height, info.format);
403
+ * ```
404
+ */
405
+
376
406
  /**
377
407
  * Get library version
378
408
  */
379
409
  declare function version(): string;
410
+
380
411
  declare const _default: {
381
412
  metadata: typeof metadata;
382
413
  metadataSync: typeof metadataSync;
package/dist/index.d.ts CHANGED
@@ -157,28 +157,7 @@ interface TransformOptions {
157
157
  }
158
158
 
159
159
  /**
160
- * bun-image-turbo - High-performance image processing for Bun and Node.js
161
- *
162
- * @module bun-image-turbo
163
- * @author Aissam Irhir <aissamirhir@gmail.com>
164
- *
165
- * @example
166
- * ```typescript
167
- * import { resize, toWebp, metadata } from 'bun-image-turbo';
168
- *
169
- * // Read image
170
- * const input = await Bun.file('input.jpg').arrayBuffer();
171
- *
172
- * // Resize image
173
- * const resized = await resize(Buffer.from(input), { width: 800, height: 600 });
174
- *
175
- * // Convert to WebP
176
- * const webp = await toWebp(Buffer.from(input), { quality: 85 });
177
- *
178
- * // Get metadata
179
- * const info = await metadata(Buffer.from(input));
180
- * console.log(info.width, info.height, info.format);
181
- * ```
160
+ * Metadata API functions
182
161
  */
183
162
 
184
163
  /**
@@ -194,6 +173,15 @@ interface TransformOptions {
194
173
  * ```
195
174
  */
196
175
  declare function metadata(input: Buffer): Promise<ImageMetadata>;
176
+ /**
177
+ * Get image metadata synchronously
178
+ */
179
+ declare function metadataSync(input: Buffer): ImageMetadata;
180
+
181
+ /**
182
+ * Resize API functions
183
+ */
184
+
197
185
  /**
198
186
  * Resize image asynchronously
199
187
  *
@@ -218,6 +206,15 @@ declare function metadata(input: Buffer): Promise<ImageMetadata>;
218
206
  * ```
219
207
  */
220
208
  declare function resize(input: Buffer, options: ResizeOptions): Promise<Buffer>;
209
+ /**
210
+ * Resize image synchronously
211
+ */
212
+ declare function resizeSync(input: Buffer, options: ResizeOptions): Buffer;
213
+
214
+ /**
215
+ * Image encoding/format conversion API functions
216
+ */
217
+
221
218
  /**
222
219
  * Convert image to JPEG asynchronously
223
220
  *
@@ -231,6 +228,10 @@ declare function resize(input: Buffer, options: ResizeOptions): Promise<Buffer>;
231
228
  * ```
232
229
  */
233
230
  declare function toJpeg(input: Buffer, options?: JpegOptions): Promise<Buffer>;
231
+ /**
232
+ * Convert image to JPEG synchronously
233
+ */
234
+ declare function toJpegSync(input: Buffer, options?: JpegOptions): Buffer;
234
235
  /**
235
236
  * Convert image to PNG asynchronously
236
237
  *
@@ -244,6 +245,10 @@ declare function toJpeg(input: Buffer, options?: JpegOptions): Promise<Buffer>;
244
245
  * ```
245
246
  */
246
247
  declare function toPng(input: Buffer, options?: PngOptions): Promise<Buffer>;
248
+ /**
249
+ * Convert image to PNG synchronously
250
+ */
251
+ declare function toPngSync(input: Buffer, options?: PngOptions): Buffer;
247
252
  /**
248
253
  * Convert image to WebP asynchronously
249
254
  *
@@ -261,6 +266,15 @@ declare function toPng(input: Buffer, options?: PngOptions): Promise<Buffer>;
261
266
  * ```
262
267
  */
263
268
  declare function toWebp(input: Buffer, options?: WebPOptions): Promise<Buffer>;
269
+ /**
270
+ * Convert image to WebP synchronously
271
+ */
272
+ declare function toWebpSync(input: Buffer, options?: WebPOptions): Buffer;
273
+
274
+ /**
275
+ * Transform API functions
276
+ */
277
+
264
278
  /**
265
279
  * Transform image with multiple operations asynchronously
266
280
  *
@@ -282,6 +296,15 @@ declare function toWebp(input: Buffer, options?: WebPOptions): Promise<Buffer>;
282
296
  * ```
283
297
  */
284
298
  declare function transform(input: Buffer, options: TransformOptions): Promise<Buffer>;
299
+ /**
300
+ * Transform image with multiple operations synchronously
301
+ */
302
+ declare function transformSync(input: Buffer, options: TransformOptions): Buffer;
303
+
304
+ /**
305
+ * Blurhash API functions
306
+ */
307
+
285
308
  /**
286
309
  * Generate blurhash from image asynchronously
287
310
  *
@@ -299,34 +322,15 @@ declare function transform(input: Buffer, options: TransformOptions): Promise<Bu
299
322
  * ```
300
323
  */
301
324
  declare function blurhash(input: Buffer, componentsX?: number, componentsY?: number): Promise<BlurHashResult>;
302
- /**
303
- * Get image metadata synchronously
304
- */
305
- declare function metadataSync(input: Buffer): ImageMetadata;
306
- /**
307
- * Resize image synchronously
308
- */
309
- declare function resizeSync(input: Buffer, options: ResizeOptions): Buffer;
310
- /**
311
- * Convert image to JPEG synchronously
312
- */
313
- declare function toJpegSync(input: Buffer, options?: JpegOptions): Buffer;
314
- /**
315
- * Convert image to PNG synchronously
316
- */
317
- declare function toPngSync(input: Buffer, options?: PngOptions): Buffer;
318
- /**
319
- * Convert image to WebP synchronously
320
- */
321
- declare function toWebpSync(input: Buffer, options?: WebPOptions): Buffer;
322
- /**
323
- * Transform image with multiple operations synchronously
324
- */
325
- declare function transformSync(input: Buffer, options: TransformOptions): Buffer;
326
325
  /**
327
326
  * Generate blurhash from image synchronously
328
327
  */
329
328
  declare function blurhashSync(input: Buffer, componentsX?: number, componentsY?: number): BlurHashResult;
329
+
330
+ /**
331
+ * EXIF metadata API functions
332
+ */
333
+
330
334
  /**
331
335
  * Write EXIF metadata to an image asynchronously
332
336
  *
@@ -373,10 +377,37 @@ declare function stripExif(input: Buffer): Promise<Buffer>;
373
377
  * Supports JPEG and WebP formats.
374
378
  */
375
379
  declare function stripExifSync(input: Buffer): Buffer;
380
+
381
+ /**
382
+ * bun-image-turbo - High-performance image processing for Bun and Node.js
383
+ *
384
+ * @module bun-image-turbo
385
+ * @author Aissam Irhir <aissamirhir@gmail.com>
386
+ *
387
+ * @example
388
+ * ```typescript
389
+ * import { resize, toWebp, metadata } from 'bun-image-turbo';
390
+ *
391
+ * // Read image
392
+ * const input = await Bun.file('input.jpg').arrayBuffer();
393
+ *
394
+ * // Resize image
395
+ * const resized = await resize(Buffer.from(input), { width: 800, height: 600 });
396
+ *
397
+ * // Convert to WebP
398
+ * const webp = await toWebp(Buffer.from(input), { quality: 85 });
399
+ *
400
+ * // Get metadata
401
+ * const info = await metadata(Buffer.from(input));
402
+ * console.log(info.width, info.height, info.format);
403
+ * ```
404
+ */
405
+
376
406
  /**
377
407
  * Get library version
378
408
  */
379
409
  declare function version(): string;
410
+
380
411
  declare const _default: {
381
412
  metadata: typeof metadata;
382
413
  metadataSync: typeof metadataSync;
package/dist/index.js CHANGED
@@ -42,17 +42,21 @@ __export(index_exports, {
42
42
  writeExifSync: () => writeExifSync
43
43
  });
44
44
  module.exports = __toCommonJS(index_exports);
45
+
46
+ // src/loader.ts
45
47
  var import_fs = require("fs");
46
48
  var import_path = require("path");
47
49
  var import_url = require("url");
50
+ var import_module = require("module");
48
51
  var import_meta = {};
49
- var getCurrentDir = () => {
52
+ var nativeRequire = typeof import_meta?.url === "string" ? (0, import_module.createRequire)(import_meta.url) : typeof require !== "undefined" ? require : null;
53
+ function getCurrentDir() {
50
54
  try {
51
55
  return (0, import_path.dirname)((0, import_url.fileURLToPath)(import_meta.url));
52
56
  } catch {
53
57
  return __dirname;
54
58
  }
55
- };
59
+ }
56
60
  function loadNativeBinding() {
57
61
  const platform = process.platform;
58
62
  const arch = process.arch;
@@ -91,14 +95,14 @@ function loadNativeBinding() {
91
95
  for (const modulePath of possiblePaths) {
92
96
  try {
93
97
  if ((0, import_fs.existsSync)(modulePath)) {
94
- return require(modulePath);
98
+ return nativeRequire(modulePath);
95
99
  }
96
100
  } catch {
97
101
  continue;
98
102
  }
99
103
  }
100
104
  try {
101
- return require(optionalPackageName);
105
+ return nativeRequire(optionalPackageName);
102
106
  } catch {
103
107
  }
104
108
  throw new Error(
@@ -106,6 +110,16 @@ function loadNativeBinding() {
106
110
  );
107
111
  }
108
112
  var native = loadNativeBinding();
113
+
114
+ // src/api/metadata.ts
115
+ async function metadata(input) {
116
+ return native.metadata(input);
117
+ }
118
+ function metadataSync(input) {
119
+ return native.metadataSync(input);
120
+ }
121
+
122
+ // src/converters.ts
109
123
  function toNapiFilter(filter) {
110
124
  if (!filter) return void 0;
111
125
  return filter.charAt(0).toUpperCase() + filter.slice(1);
@@ -163,48 +177,52 @@ function toNapiTransformOptions(options) {
163
177
  }
164
178
  return result;
165
179
  }
166
- async function metadata(input) {
167
- return native.metadata(input);
168
- }
180
+
181
+ // src/api/resize.ts
169
182
  async function resize(input, options) {
170
183
  return native.resize(input, toNapiResizeOptions(options));
171
184
  }
172
- async function toJpeg(input, options) {
173
- return native.toJpeg(input, options);
174
- }
175
- async function toPng(input, options) {
176
- return native.toPng(input, options);
177
- }
178
- async function toWebp(input, options) {
179
- return native.toWebp(input, options);
180
- }
181
- async function transform(input, options) {
182
- return native.transform(input, toNapiTransformOptions(options));
183
- }
184
- async function blurhash(input, componentsX, componentsY) {
185
- return native.blurhash(input, componentsX, componentsY);
186
- }
187
- function metadataSync(input) {
188
- return native.metadataSync(input);
189
- }
190
185
  function resizeSync(input, options) {
191
186
  return native.resizeSync(input, toNapiResizeOptions(options));
192
187
  }
188
+
189
+ // src/api/encode.ts
190
+ async function toJpeg(input, options) {
191
+ return native.toJpeg(input, options);
192
+ }
193
193
  function toJpegSync(input, options) {
194
194
  return native.toJpegSync(input, options);
195
195
  }
196
+ async function toPng(input, options) {
197
+ return native.toPng(input, options);
198
+ }
196
199
  function toPngSync(input, options) {
197
200
  return native.toPngSync(input, options);
198
201
  }
202
+ async function toWebp(input, options) {
203
+ return native.toWebp(input, options);
204
+ }
199
205
  function toWebpSync(input, options) {
200
206
  return native.toWebpSync(input, options);
201
207
  }
208
+
209
+ // src/api/transform.ts
210
+ async function transform(input, options) {
211
+ return native.transform(input, toNapiTransformOptions(options));
212
+ }
202
213
  function transformSync(input, options) {
203
214
  return native.transformSync(input, toNapiTransformOptions(options));
204
215
  }
216
+
217
+ // src/api/blurhash.ts
218
+ async function blurhash(input, componentsX, componentsY) {
219
+ return native.blurhash(input, componentsX, componentsY);
220
+ }
205
221
  function blurhashSync(input, componentsX, componentsY) {
206
222
  return native.blurhashSync(input, componentsX, componentsY);
207
223
  }
224
+
225
+ // src/api/exif.ts
208
226
  async function writeExif(input, options) {
209
227
  return native.writeExif(input, options);
210
228
  }
@@ -217,6 +235,8 @@ async function stripExif(input) {
217
235
  function stripExifSync(input) {
218
236
  return native.stripExifSync(input);
219
237
  }
238
+
239
+ // src/index.ts
220
240
  function version() {
221
241
  return native.version();
222
242
  }
package/dist/index.mjs CHANGED
@@ -5,17 +5,19 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
5
5
  throw Error('Dynamic require of "' + x + '" is not supported');
6
6
  });
7
7
 
8
- // src/index.ts
8
+ // src/loader.ts
9
9
  import { existsSync } from "fs";
10
10
  import { join, dirname } from "path";
11
11
  import { fileURLToPath } from "url";
12
- var getCurrentDir = () => {
12
+ import { createRequire } from "module";
13
+ var nativeRequire = typeof import.meta?.url === "string" ? createRequire(import.meta.url) : typeof __require !== "undefined" ? __require : null;
14
+ function getCurrentDir() {
13
15
  try {
14
16
  return dirname(fileURLToPath(import.meta.url));
15
17
  } catch {
16
18
  return __dirname;
17
19
  }
18
- };
20
+ }
19
21
  function loadNativeBinding() {
20
22
  const platform = process.platform;
21
23
  const arch = process.arch;
@@ -54,14 +56,14 @@ function loadNativeBinding() {
54
56
  for (const modulePath of possiblePaths) {
55
57
  try {
56
58
  if (existsSync(modulePath)) {
57
- return __require(modulePath);
59
+ return nativeRequire(modulePath);
58
60
  }
59
61
  } catch {
60
62
  continue;
61
63
  }
62
64
  }
63
65
  try {
64
- return __require(optionalPackageName);
66
+ return nativeRequire(optionalPackageName);
65
67
  } catch {
66
68
  }
67
69
  throw new Error(
@@ -69,6 +71,16 @@ function loadNativeBinding() {
69
71
  );
70
72
  }
71
73
  var native = loadNativeBinding();
74
+
75
+ // src/api/metadata.ts
76
+ async function metadata(input) {
77
+ return native.metadata(input);
78
+ }
79
+ function metadataSync(input) {
80
+ return native.metadataSync(input);
81
+ }
82
+
83
+ // src/converters.ts
72
84
  function toNapiFilter(filter) {
73
85
  if (!filter) return void 0;
74
86
  return filter.charAt(0).toUpperCase() + filter.slice(1);
@@ -126,48 +138,52 @@ function toNapiTransformOptions(options) {
126
138
  }
127
139
  return result;
128
140
  }
129
- async function metadata(input) {
130
- return native.metadata(input);
131
- }
141
+
142
+ // src/api/resize.ts
132
143
  async function resize(input, options) {
133
144
  return native.resize(input, toNapiResizeOptions(options));
134
145
  }
135
- async function toJpeg(input, options) {
136
- return native.toJpeg(input, options);
137
- }
138
- async function toPng(input, options) {
139
- return native.toPng(input, options);
140
- }
141
- async function toWebp(input, options) {
142
- return native.toWebp(input, options);
143
- }
144
- async function transform(input, options) {
145
- return native.transform(input, toNapiTransformOptions(options));
146
- }
147
- async function blurhash(input, componentsX, componentsY) {
148
- return native.blurhash(input, componentsX, componentsY);
149
- }
150
- function metadataSync(input) {
151
- return native.metadataSync(input);
152
- }
153
146
  function resizeSync(input, options) {
154
147
  return native.resizeSync(input, toNapiResizeOptions(options));
155
148
  }
149
+
150
+ // src/api/encode.ts
151
+ async function toJpeg(input, options) {
152
+ return native.toJpeg(input, options);
153
+ }
156
154
  function toJpegSync(input, options) {
157
155
  return native.toJpegSync(input, options);
158
156
  }
157
+ async function toPng(input, options) {
158
+ return native.toPng(input, options);
159
+ }
159
160
  function toPngSync(input, options) {
160
161
  return native.toPngSync(input, options);
161
162
  }
163
+ async function toWebp(input, options) {
164
+ return native.toWebp(input, options);
165
+ }
162
166
  function toWebpSync(input, options) {
163
167
  return native.toWebpSync(input, options);
164
168
  }
169
+
170
+ // src/api/transform.ts
171
+ async function transform(input, options) {
172
+ return native.transform(input, toNapiTransformOptions(options));
173
+ }
165
174
  function transformSync(input, options) {
166
175
  return native.transformSync(input, toNapiTransformOptions(options));
167
176
  }
177
+
178
+ // src/api/blurhash.ts
179
+ async function blurhash(input, componentsX, componentsY) {
180
+ return native.blurhash(input, componentsX, componentsY);
181
+ }
168
182
  function blurhashSync(input, componentsX, componentsY) {
169
183
  return native.blurhashSync(input, componentsX, componentsY);
170
184
  }
185
+
186
+ // src/api/exif.ts
171
187
  async function writeExif(input, options) {
172
188
  return native.writeExif(input, options);
173
189
  }
@@ -180,6 +196,8 @@ async function stripExif(input) {
180
196
  function stripExifSync(input) {
181
197
  return native.stripExifSync(input);
182
198
  }
199
+
200
+ // src/index.ts
183
201
  function version() {
184
202
  return native.version();
185
203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-image-turbo",
3
- "version": "1.3.0",
3
+ "version": "1.4.5",
4
4
  "author": "Aissam Irhir <aissamirhir@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -64,6 +64,15 @@
64
64
  "turbo"
65
65
  ],
66
66
  "license": "MIT",
67
+ "optionalDependencies": {
68
+ "bun-image-turbo-darwin-arm64": "1.4.5",
69
+ "bun-image-turbo-darwin-x64": "1.4.5",
70
+ "bun-image-turbo-linux-arm64-gnu": "1.4.5",
71
+ "bun-image-turbo-linux-x64-gnu": "1.4.5",
72
+ "bun-image-turbo-linux-x64-musl": "1.4.5",
73
+ "bun-image-turbo-win32-arm64-msvc": "1.4.5",
74
+ "bun-image-turbo-win32-x64-msvc": "1.4.5"
75
+ },
67
76
  "napi": {
68
77
  "name": "image-turbo",
69
78
  "binaryName": "image-turbo",
@@ -85,19 +94,17 @@
85
94
  "build:all": "bun run build && bun run build:ts",
86
95
  "artifacts": "napi artifacts",
87
96
  "version": "napi version",
88
- "test": "bun test",
97
+ "test": "bun test test/local",
98
+ "test:local": "bun test test/local",
99
+ "test:bun": "cd test/packages/bun && bun install && bun test",
100
+ "test:npm": "cd test/packages/npm && npm install && npm test",
101
+ "test:yarn": "cd test/packages/yarn && yarn install && yarn test",
102
+ "test:pnpm": "cd test/packages/pnpm && pnpm install && pnpm test",
103
+ "test:packages": "bun run test:bun && bun run test:npm && bun run test:yarn && bun run test:pnpm",
104
+ "test:all": "bun run test:local && bun run test:packages",
89
105
  "bench": "bun run benchmarks/bench.ts",
90
106
  "lint": "eslint src",
91
107
  "clean": "rm -rf dist *.node npm"
92
108
  },
93
- "types": "./dist/index.d.ts",
94
- "optionalDependencies": {
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
- }
109
+ "types": "./dist/index.d.ts"
103
110
  }