lightdrift-libraw 1.0.0-alpha.5 → 1.0.0-alpha.6

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 (3) hide show
  1. package/lib/index.d.ts +641 -647
  2. package/lib/index.js +46 -21
  3. package/package.json +1 -1
package/lib/index.d.ts CHANGED
@@ -1,647 +1,641 @@
1
- /**
2
- * TypeScript definitions for LibRaw Node.js wrapper
3
- * Provides type-safe access to LibRaw functionality for RAW image processing
4
- */
5
-
6
- export interface LibRawMetadata {
7
- /** Camera manufacturer */
8
- make?: string;
9
- /** Camera model */
10
- model?: string;
11
- /** Camera software/firmware */
12
- software?: string;
13
- /** Processed image width */
14
- width: number;
15
- /** Processed image height */
16
- height: number;
17
- /** RAW image width */
18
- rawWidth: number;
19
- /** RAW image height */
20
- rawHeight: number;
21
- /** Number of color channels */
22
- colors: number;
23
- /** Color filter array pattern */
24
- filters: number;
25
- /** ISO sensitivity */
26
- iso?: number;
27
- /** Shutter speed in seconds */
28
- shutterSpeed?: number;
29
- /** Aperture value (f-number) */
30
- aperture?: number;
31
- /** Focal length in mm */
32
- focalLength?: number;
33
- /** Timestamp of image capture */
34
- timestamp?: number;
35
- }
36
-
37
- export interface LibRawAdvancedMetadata {
38
- /** Normalized camera manufacturer */
39
- normalizedMake?: string;
40
- /** Normalized camera model */
41
- normalizedModel?: string;
42
- /** Number of RAW images in file */
43
- rawCount: number;
44
- /** DNG version number */
45
- dngVersion: number;
46
- /** Foveon sensor indicator */
47
- is_foveon: number;
48
- /** Color transformation matrix (4x3) */
49
- colorMatrix: number[][];
50
- /** Camera white balance multipliers */
51
- camMul: number[];
52
- /** Preprocessing multipliers */
53
- preMul: number[];
54
- /** Sensor black level */
55
- blackLevel: number;
56
- /** Maximum data value */
57
- dataMaximum: number;
58
- /** Sensor white level */
59
- whiteLevel: number;
60
- }
61
-
62
- export interface LibRawImageSize {
63
- /** Processed image width */
64
- width: number;
65
- /** Processed image height */
66
- height: number;
67
- /** RAW image width */
68
- rawWidth: number;
69
- /** RAW image height */
70
- rawHeight: number;
71
- /** Top margin in pixels */
72
- topMargin: number;
73
- /** Left margin in pixels */
74
- leftMargin: number;
75
- /** Internal width */
76
- iWidth: number;
77
- /** Internal height */
78
- iHeight: number;
79
- }
80
-
81
- export interface LibRawLensInfo {
82
- /** Lens name/model */
83
- lensName?: string;
84
- /** Lens manufacturer */
85
- lensMake?: string;
86
- /** Lens serial number */
87
- lensSerial?: string;
88
- /** Internal lens serial number */
89
- internalLensSerial?: string;
90
- /** Minimum focal length */
91
- minFocal?: number;
92
- /** Maximum focal length */
93
- maxFocal?: number;
94
- /** Maximum aperture at minimum focal length */
95
- maxAp4MinFocal?: number;
96
- /** Maximum aperture at maximum focal length */
97
- maxAp4MaxFocal?: number;
98
- /** EXIF maximum aperture */
99
- exifMaxAp?: number;
100
- /** Focal length in 35mm equivalent */
101
- focalLengthIn35mmFormat?: number;
102
- }
103
-
104
- export interface LibRawColorInfo {
105
- /** Number of color channels */
106
- colors: number;
107
- /** Color filter array pattern */
108
- filters: number;
109
- /** Sensor black level */
110
- blackLevel: number;
111
- /** Maximum data value */
112
- dataMaximum: number;
113
- /** Sensor white level */
114
- whiteLevel: number;
115
- /** Color profile length */
116
- profileLength?: number;
117
- /** RGB to camera space matrix (3x4) */
118
- rgbCam: number[][];
119
- /** Camera white balance multipliers */
120
- camMul: number[];
121
- }
122
-
123
- export interface LibRawOutputParams {
124
- /** Gamma correction curve [gamma, toe_slope] */
125
- gamma?: [number, number];
126
- /** Brightness adjustment (0.25-8.0) */
127
- bright?: number;
128
- /** Output color space (0=raw, 1=sRGB, 2=Adobe, 3=Wide, 4=ProPhoto, 5=XYZ, 6=ACES) */
129
- output_color?: number;
130
- /** Output bits per sample (8 or 16) */
131
- output_bps?: number;
132
- /** Manual white balance multipliers [R, G, B, G2] */
133
- user_mul?: [number, number, number, number];
134
- /** Disable automatic brightness adjustment */
135
- no_auto_bright?: boolean;
136
- /** Highlight recovery mode (0-9) */
137
- highlight?: number;
138
- /** Output TIFF format instead of PPM */
139
- output_tiff?: boolean;
140
- }
141
-
142
- export interface LibRawImageData {
143
- /** Image type (1=JPEG, 3=PPM/TIFF) */
144
- type: number;
145
- /** Image height in pixels */
146
- height: number;
147
- /** Image width in pixels */
148
- width: number;
149
- /** Number of color channels */
150
- colors: number;
151
- /** Bits per channel */
152
- bits: number;
153
- /** Total data size in bytes */
154
- dataSize: number;
155
- /** Raw image data buffer */
156
- data: Buffer;
157
- }
158
-
159
- export interface LibRawJPEGOptions {
160
- /** JPEG quality (1-100) */
161
- quality?: number;
162
- /** Target width (maintains aspect ratio if height not specified) */
163
- width?: number;
164
- /** Target height (maintains aspect ratio if width not specified) */
165
- height?: number;
166
- /** Use progressive JPEG */
167
- progressive?: boolean;
168
- /** Use mozjpeg encoder for better compression */
169
- mozjpeg?: boolean;
170
- /** Chroma subsampling ('4:4:4', '4:2:0') - Note: 4:2:2 maps to 4:4:4 */
171
- chromaSubsampling?: '4:4:4' | '4:2:2' | '4:2:0';
172
- /** Enable trellis quantisation */
173
- trellisQuantisation?: boolean;
174
- /** Optimize scan order */
175
- optimizeScans?: boolean;
176
- /** Overshoot deringing */
177
- overshootDeringing?: boolean;
178
- /** Optimize Huffman coding */
179
- optimizeCoding?: boolean;
180
- /** Output color space */
181
- colorSpace?: 'srgb' | 'rec2020' | 'p3' | 'cmyk';
182
- /** Enable fast mode for better performance */
183
- fastMode?: boolean;
184
- /** Encoding effort (1=fastest, 9=slowest) */
185
- effort?: number;
186
- /** Maximum concurrency for batch operations */
187
- maxConcurrency?: number;
188
- }
189
-
190
- export interface LibRawOptimalSettings {
191
- quality: number;
192
- progressive: boolean;
193
- mozjpeg: boolean;
194
- chromaSubsampling: string;
195
- effort: number;
196
- reasoning: string;
197
- }
198
-
199
- export interface LibRawBufferResult {
200
- /** Buffer creation success status */
201
- success: boolean;
202
- /** Raw binary data buffer */
203
- buffer: Buffer;
204
- /** Buffer metadata */
205
- metadata: {
206
- /** Original image dimensions */
207
- originalDimensions?: {
208
- width: number;
209
- height: number;
210
- };
211
- /** Output image dimensions */
212
- outputDimensions?: {
213
- width: number;
214
- height: number;
215
- };
216
- /** Processed dimensions */
217
- dimensions?: {
218
- width: number;
219
- height: number;
220
- };
221
- /** File size information */
222
- fileSize: {
223
- original?: number;
224
- compressed: number;
225
- compressionRatio?: string;
226
- };
227
- /** Processing performance */
228
- processing: {
229
- timeMs: string;
230
- throughputMBps?: string;
231
- fromCache?: boolean;
232
- };
233
- /** Format-specific options */
234
- jpegOptions?: object;
235
- pngOptions?: object;
236
- tiffOptions?: object;
237
- webpOptions?: object;
238
- avifOptions?: object;
239
- /** Format type */
240
- format?: string;
241
- };
242
- }
243
-
244
- export interface LibRawImageConversionOptions {
245
- /** Target width (maintains aspect ratio if height not specified) */
246
- width?: number;
247
- /** Target height (maintains aspect ratio if width not specified) */
248
- height?: number;
249
- /** Output color space */
250
- colorSpace?: 'srgb' | 'rec2020' | 'p3' | 'cmyk';
251
- /** Enable fast mode for better performance */
252
- fastMode?: boolean;
253
- }
254
-
255
- export interface LibRawPNGOptions extends LibRawImageConversionOptions {
256
- /** PNG compression level (0-9) */
257
- compressionLevel?: number;
258
- /** Use progressive PNG */
259
- progressive?: boolean;
260
- }
261
-
262
- export interface LibRawTIFFOptions extends LibRawImageConversionOptions {
263
- /** TIFF compression type */
264
- compression?: 'none' | 'lzw' | 'jpeg' | 'zip';
265
- /** JPEG quality when using JPEG compression */
266
- quality?: number;
267
- /** Create pyramidal TIFF */
268
- pyramid?: boolean;
269
- }
270
-
271
- export interface LibRawWebPOptions extends LibRawImageConversionOptions {
272
- /** WebP quality (1-100) */
273
- quality?: number;
274
- /** Use lossless WebP */
275
- lossless?: boolean;
276
- /** Encoding effort (0-6) */
277
- effort?: number;
278
- }
279
-
280
- export interface LibRawAVIFOptions extends LibRawImageConversionOptions {
281
- /** AVIF quality (1-100) */
282
- quality?: number;
283
- /** Use lossless AVIF */
284
- lossless?: boolean;
285
- /** Encoding effort (0-9) */
286
- effort?: number;
287
- }
288
-
289
- export interface LibRawThumbnailJPEGOptions {
290
- /** JPEG quality (1-100) */
291
- quality?: number;
292
- /** Maximum dimension size */
293
- maxSize?: number;
294
- }
295
-
296
- export interface LibRawJPEGResult {
297
- /** Conversion success status */
298
- success: boolean;
299
- /** Output file path */
300
- outputPath: string;
301
- /** Conversion metadata */
302
- metadata: {
303
- /** Original image dimensions */
304
- originalDimensions: {
305
- width: number;
306
- height: number;
307
- };
308
- /** Output image dimensions */
309
- outputDimensions: {
310
- width: number;
311
- height: number;
312
- };
313
- /** File size information */
314
- fileSize: {
315
- original: number;
316
- compressed: number;
317
- compressionRatio: string;
318
- };
319
- /** Processing performance */
320
- processing: {
321
- timeMs: string;
322
- throughputMBps: string;
323
- };
324
- /** Applied JPEG options */
325
- jpegOptions: object;
326
- };
327
- }
328
-
329
- export interface LibRawBatchResult {
330
- /** Successfully processed files */
331
- successful: Array<{
332
- input: string;
333
- output: string;
334
- result: LibRawJPEGResult;
335
- }>;
336
- /** Failed files */
337
- failed: Array<{
338
- input: string;
339
- error: string;
340
- }>;
341
- /** Processing summary */
342
- summary: {
343
- total: number;
344
- processed: number;
345
- errors: number;
346
- totalProcessingTime: number;
347
- averageCompressionRatio: string;
348
- totalOriginalSize: number;
349
- totalCompressedSize: number;
350
- averageProcessingTimePerFile: string;
351
- };
352
- }
353
-
354
- export interface LibRawOptimalSettings {
355
- /** Recommended JPEG settings */
356
- recommended: LibRawJPEGOptions & {
357
- reasoning: string[];
358
- };
359
- /** Image analysis results */
360
- imageAnalysis: {
361
- dimensions: {
362
- width: number;
363
- height: number;
364
- area: number;
365
- };
366
- category: 'high-resolution' | 'medium-resolution' | 'low-resolution';
367
- camera: {
368
- make?: string;
369
- model?: string;
370
- };
371
- };
372
- }
373
-
374
- export declare class LibRaw {
375
- constructor();
376
-
377
- // ============== FILE OPERATIONS ==============
378
- /**
379
- * Load RAW image from file
380
- * @param filename Path to RAW image file
381
- */
382
- loadFile(filename: string): Promise<boolean>;
383
-
384
- /**
385
- * Load RAW image from buffer
386
- * @param buffer Binary data buffer containing RAW image
387
- */
388
- loadBuffer(buffer: Buffer): Promise<boolean>;
389
-
390
- /**
391
- * Close current image and free resources
392
- */
393
- close(): Promise<boolean>;
394
-
395
- // ============== METADATA & INFORMATION ==============
396
- /**
397
- * Get basic image metadata and EXIF information
398
- */
399
- getMetadata(): Promise<LibRawMetadata>;
400
-
401
- /**
402
- * Get image size and margin information
403
- */
404
- getImageSize(): Promise<LibRawImageSize>;
405
-
406
- /**
407
- * Get advanced metadata including color matrices
408
- */
409
- getAdvancedMetadata(): Promise<LibRawAdvancedMetadata>;
410
-
411
- /**
412
- * Get lens information from EXIF data
413
- */
414
- getLensInfo(): Promise<LibRawLensInfo>;
415
-
416
- /**
417
- * Get color space and sensor information
418
- */
419
- getColorInfo(): Promise<LibRawColorInfo>;
420
-
421
- // ============== IMAGE PROCESSING ==============
422
- /**
423
- * Unpack thumbnail from RAW file
424
- */
425
- unpackThumbnail(): Promise<boolean>;
426
-
427
- /**
428
- * Process RAW image with current settings
429
- */
430
- processImage(): Promise<boolean>;
431
-
432
- /**
433
- * Subtract black level from image data
434
- */
435
- subtractBlack(): Promise<boolean>;
436
-
437
- /**
438
- * Convert RAW data to RGB image
439
- */
440
- raw2Image(): Promise<boolean>;
441
-
442
- /**
443
- * Adjust image maximum values
444
- */
445
- adjustMaximum(): Promise<boolean>;
446
-
447
- // ============== MEMORY IMAGE CREATION ==============
448
- /**
449
- * Create processed image in memory
450
- */
451
- createMemoryImage(): Promise<LibRawImageData>;
452
-
453
- /**
454
- * Create thumbnail image in memory
455
- */
456
- createMemoryThumbnail(): Promise<LibRawImageData>;
457
-
458
- // ============== FILE WRITERS ==============
459
- /**
460
- * Write processed image as PPM file
461
- * @param filename Output PPM file path
462
- */
463
- writePPM(filename: string): Promise<boolean>;
464
-
465
- /**
466
- * Write processed image as TIFF file
467
- * @param filename Output TIFF file path
468
- */
469
- writeTIFF(filename: string): Promise<boolean>;
470
-
471
- /**
472
- * Write thumbnail as JPEG file
473
- * @param filename Output JPEG file path
474
- */
475
- writeThumbnail(filename: string): Promise<boolean>;
476
-
477
- // ============== CONFIGURATION & SETTINGS ==============
478
- /**
479
- * Set output processing parameters
480
- * @param params Output parameters configuration
481
- */
482
- setOutputParams(params: LibRawOutputParams): Promise<boolean>;
483
-
484
- /**
485
- * Get current output processing parameters
486
- */
487
- getOutputParams(): Promise<LibRawOutputParams>;
488
-
489
- // ============== UTILITY FUNCTIONS ==============
490
- /**
491
- * Check if image uses floating point values
492
- */
493
- isFloatingPoint(): Promise<boolean>;
494
-
495
- /**
496
- * Check if image is from Fuji camera and rotated
497
- */
498
- isFujiRotated(): Promise<boolean>;
499
-
500
- /**
501
- * Check if image is sRAW format
502
- */
503
- isSRAW(): Promise<boolean>;
504
-
505
- /**
506
- * Check if file contains JPEG thumbnail
507
- */
508
- isJPEGThumb(): Promise<boolean>;
509
-
510
- /**
511
- * Get current error count
512
- */
513
- errorCount(): Promise<number>;
514
-
515
- // ============== MEMORY STREAM OPERATIONS (NEW FEATURE) ==============
516
- /**
517
- * Create processed image as JPEG buffer in memory
518
- * @param options JPEG conversion options
519
- */
520
- createJPEGBuffer(options?: LibRawJPEGOptions): Promise<LibRawBufferResult>;
521
-
522
- /**
523
- * Create processed image as PNG buffer in memory
524
- * @param options PNG conversion options
525
- */
526
- createPNGBuffer(options?: LibRawPNGOptions): Promise<LibRawBufferResult>;
527
-
528
- /**
529
- * Create processed image as TIFF buffer in memory
530
- * @param options TIFF conversion options
531
- */
532
- createTIFFBuffer(options?: LibRawTIFFOptions): Promise<LibRawBufferResult>;
533
-
534
- /**
535
- * Create processed image as WebP buffer in memory
536
- * @param options WebP conversion options
537
- */
538
- createWebPBuffer(options?: LibRawWebPOptions): Promise<LibRawBufferResult>;
539
-
540
- /**
541
- * Create processed image as AVIF buffer in memory
542
- * @param options AVIF conversion options
543
- */
544
- createAVIFBuffer(options?: LibRawAVIFOptions): Promise<LibRawBufferResult>;
545
-
546
- /**
547
- * Create raw PPM buffer from processed image data
548
- */
549
- createPPMBuffer(): Promise<LibRawBufferResult>;
550
-
551
- /**
552
- * Create thumbnail as JPEG buffer in memory
553
- * @param options JPEG options for thumbnail
554
- */
555
- createThumbnailJPEGBuffer(options?: LibRawThumbnailJPEGOptions): Promise<LibRawBufferResult>;
556
-
557
- // ============== JPEG CONVERSION (NEW FEATURE) ==============
558
- /**
559
- * Convert RAW to JPEG with advanced options
560
- * @param outputPath Output JPEG file path
561
- * @param options JPEG conversion options
562
- */
563
- convertToJPEG(outputPath: string, options?: LibRawJPEGOptions): Promise<LibRawJPEGResult>;
564
-
565
- /**
566
- * Batch convert multiple RAW files to JPEG
567
- * @param inputPaths Array of input RAW file paths
568
- * @param outputDir Output directory for JPEG files
569
- * @param options JPEG conversion options
570
- */
571
- batchConvertToJPEG(inputPaths: string[], outputDir: string, options?: LibRawJPEGOptions): Promise<LibRawBatchResult>;
572
-
573
- /**
574
- * Get optimal JPEG conversion settings based on image analysis
575
- * @param analysisOptions Options for image analysis
576
- */
577
- getOptimalJPEGSettings(analysisOptions?: { usage?: 'web' | 'print' | 'archive' }): Promise<LibRawOptimalSettings>;
578
-
579
- /**
580
- * High-performance JPEG conversion with minimal processing for speed
581
- * @param outputPath Output JPEG file path
582
- * @param options Speed-optimized JPEG options
583
- */
584
- convertToJPEGFast(outputPath: string, options?: LibRawJPEGOptions): Promise<LibRawJPEGResult>;
585
-
586
- /**
587
- * Create multiple JPEG sizes from single RAW (thumbnail, web, full)
588
- * @param baseOutputPath Base output path (without extension)
589
- * @param options Multi-size options
590
- */
591
- convertToJPEGMultiSize(baseOutputPath: string, options?: {
592
- sizes?: Array<{
593
- name: string;
594
- width?: number;
595
- height?: number;
596
- quality?: number;
597
- progressive?: boolean;
598
- mozjpeg?: boolean;
599
- chromaSubsampling?: string;
600
- effort?: number;
601
- }>;
602
- }): Promise<{
603
- success: boolean;
604
- sizes: Record<string, {
605
- name: string;
606
- outputPath: string;
607
- dimensions: { width: number; height: number };
608
- fileSize: number;
609
- processingTime: number;
610
- config: any;
611
- }>;
612
- originalDimensions: { width: number; height: number };
613
- totalProcessingTime: number;
614
- averageTimePerSize: string;
615
- }>;
616
-
617
- // ============== STATIC METHODS ==============
618
- /**
619
- * Get LibRaw library version
620
- */
621
- static getVersion(): string;
622
-
623
- /**
624
- * Get LibRaw library capabilities bitmask
625
- */
626
- static getCapabilities(): number;
627
-
628
- /**
629
- * Get list of supported camera models
630
- */
631
- static getCameraList(): string[];
632
-
633
- /**
634
- * Get count of supported camera models
635
- */
636
- static getCameraCount(): number;
637
- }
638
-
639
- declare const LibRaw: {
640
- new (): LibRaw;
641
- getVersion(): string;
642
- getCapabilities(): number;
643
- getCameraList(): string[];
644
- getCameraCount(): number;
645
- };
646
-
647
- export = LibRaw;
1
+ /**
2
+ * TypeScript definitions for LibRaw Node.js wrapper
3
+ * Provides type-safe access to LibRaw functionality for RAW image processing
4
+ */
5
+
6
+ declare module 'libraw' {
7
+ export interface LibRawMetadata {
8
+ /** Camera manufacturer */
9
+ make?: string;
10
+ /** Camera model */
11
+ model?: string;
12
+ /** Camera software/firmware */
13
+ software?: string;
14
+ /** Processed image width */
15
+ width: number;
16
+ /** Processed image height */
17
+ height: number;
18
+ /** RAW image width */
19
+ rawWidth: number;
20
+ /** RAW image height */
21
+ rawHeight: number;
22
+ /** Number of color channels */
23
+ colors: number;
24
+ /** Color filter array pattern */
25
+ filters: number;
26
+ /** ISO sensitivity */
27
+ iso?: number;
28
+ /** Shutter speed in seconds */
29
+ shutterSpeed?: number;
30
+ /** Aperture value (f-number) */
31
+ aperture?: number;
32
+ /** Focal length in mm */
33
+ focalLength?: number;
34
+ /** Timestamp of image capture */
35
+ timestamp?: number;
36
+ }
37
+
38
+ export interface LibRawAdvancedMetadata {
39
+ /** Normalized camera manufacturer */
40
+ normalizedMake?: string;
41
+ /** Normalized camera model */
42
+ normalizedModel?: string;
43
+ /** Number of RAW images in file */
44
+ rawCount: number;
45
+ /** DNG version number */
46
+ dngVersion: number;
47
+ /** Foveon sensor indicator */
48
+ is_foveon: number;
49
+ /** Color transformation matrix (4x3) */
50
+ colorMatrix: number[][];
51
+ /** Camera white balance multipliers */
52
+ camMul: number[];
53
+ /** Preprocessing multipliers */
54
+ preMul: number[];
55
+ /** Sensor black level */
56
+ blackLevel: number;
57
+ /** Maximum data value */
58
+ dataMaximum: number;
59
+ /** Sensor white level */
60
+ whiteLevel: number;
61
+ }
62
+
63
+ export interface LibRawImageSize {
64
+ /** Processed image width */
65
+ width: number;
66
+ /** Processed image height */
67
+ height: number;
68
+ /** RAW image width */
69
+ rawWidth: number;
70
+ /** RAW image height */
71
+ rawHeight: number;
72
+ /** Top margin in pixels */
73
+ topMargin: number;
74
+ /** Left margin in pixels */
75
+ leftMargin: number;
76
+ /** Internal width */
77
+ iWidth: number;
78
+ /** Internal height */
79
+ iHeight: number;
80
+ }
81
+
82
+ export interface LibRawLensInfo {
83
+ /** Lens name/model */
84
+ lensName?: string;
85
+ /** Lens manufacturer */
86
+ lensMake?: string;
87
+ /** Lens serial number */
88
+ lensSerial?: string;
89
+ /** Internal lens serial number */
90
+ internalLensSerial?: string;
91
+ /** Minimum focal length */
92
+ minFocal?: number;
93
+ /** Maximum focal length */
94
+ maxFocal?: number;
95
+ /** Maximum aperture at minimum focal length */
96
+ maxAp4MinFocal?: number;
97
+ /** Maximum aperture at maximum focal length */
98
+ maxAp4MaxFocal?: number;
99
+ /** EXIF maximum aperture */
100
+ exifMaxAp?: number;
101
+ /** Focal length in 35mm equivalent */
102
+ focalLengthIn35mmFormat?: number;
103
+ }
104
+
105
+ export interface LibRawColorInfo {
106
+ /** Number of color channels */
107
+ colors: number;
108
+ /** Color filter array pattern */
109
+ filters: number;
110
+ /** Sensor black level */
111
+ blackLevel: number;
112
+ /** Maximum data value */
113
+ dataMaximum: number;
114
+ /** Sensor white level */
115
+ whiteLevel: number;
116
+ /** Color profile length */
117
+ profileLength?: number;
118
+ /** RGB to camera space matrix (3x4) */
119
+ rgbCam: number[][];
120
+ /** Camera white balance multipliers */
121
+ camMul: number[];
122
+ }
123
+
124
+ export interface LibRawOutputParams {
125
+ /** Gamma correction curve [gamma, toe_slope] */
126
+ gamma?: [number, number];
127
+ /** Brightness adjustment (0.25-8.0) */
128
+ bright?: number;
129
+ /** Output color space (0=raw, 1=sRGB, 2=Adobe, 3=Wide, 4=ProPhoto, 5=XYZ, 6=ACES) */
130
+ output_color?: number;
131
+ /** Output bits per sample (8 or 16) */
132
+ output_bps?: number;
133
+ /** Manual white balance multipliers [R, G, B, G2] */
134
+ user_mul?: [number, number, number, number];
135
+ /** Disable automatic brightness adjustment */
136
+ no_auto_bright?: boolean;
137
+ /** Highlight recovery mode (0-9) */
138
+ highlight?: number;
139
+ /** Output TIFF format instead of PPM */
140
+ output_tiff?: boolean;
141
+ }
142
+
143
+ export interface LibRawImageData {
144
+ /** Image type (1=JPEG, 3=PPM/TIFF) */
145
+ type: number;
146
+ /** Image height in pixels */
147
+ height: number;
148
+ /** Image width in pixels */
149
+ width: number;
150
+ /** Number of color channels */
151
+ colors: number;
152
+ /** Bits per channel */
153
+ bits: number;
154
+ /** Total data size in bytes */
155
+ dataSize: number;
156
+ /** Raw image data buffer */
157
+ data: Buffer;
158
+ }
159
+
160
+ export interface LibRawJPEGOptions {
161
+ /** JPEG quality (1-100) */
162
+ quality?: number;
163
+ /** Target width (maintains aspect ratio if height not specified) */
164
+ width?: number;
165
+ /** Target height (maintains aspect ratio if width not specified) */
166
+ height?: number;
167
+ /** Use progressive JPEG */
168
+ progressive?: boolean;
169
+ /** Use mozjpeg encoder for better compression */
170
+ mozjpeg?: boolean;
171
+ /** Chroma subsampling ('4:4:4', '4:2:0') - Note: 4:2:2 maps to 4:4:4 */
172
+ chromaSubsampling?: '4:4:4' | '4:2:2' | '4:2:0';
173
+ /** Enable trellis quantisation */
174
+ trellisQuantisation?: boolean;
175
+ /** Optimize scan order */
176
+ optimizeScans?: boolean;
177
+ /** Overshoot deringing */
178
+ overshootDeringing?: boolean;
179
+ /** Optimize Huffman coding */
180
+ optimizeCoding?: boolean;
181
+ /** Output color space */
182
+ colorSpace?: 'srgb' | 'rec2020' | 'p3' | 'cmyk';
183
+ /** Enable fast mode for better performance */
184
+ fastMode?: boolean;
185
+ /** Encoding effort (1=fastest, 9=slowest) */
186
+ effort?: number;
187
+ /** Maximum concurrency for batch operations */
188
+ maxConcurrency?: number;
189
+ }
190
+
191
+ export interface LibRawOptimalSettings {
192
+ quality: number;
193
+ progressive: boolean;
194
+ mozjpeg: boolean;
195
+ chromaSubsampling: string;
196
+ effort: number;
197
+ reasoning: string;
198
+ }
199
+
200
+ export interface LibRawBufferResult {
201
+ /** Buffer creation success status */
202
+ success: boolean;
203
+ /** Raw binary data buffer */
204
+ buffer: Buffer;
205
+ /** Buffer metadata */
206
+ metadata: {
207
+ /** Original image dimensions */
208
+ originalDimensions?: {
209
+ width: number;
210
+ height: number;
211
+ };
212
+ /** Output image dimensions */
213
+ outputDimensions?: {
214
+ width: number;
215
+ height: number;
216
+ };
217
+ /** Processed dimensions */
218
+ dimensions?: {
219
+ width: number;
220
+ height: number;
221
+ };
222
+ /** File size information */
223
+ fileSize: {
224
+ original?: number;
225
+ compressed: number;
226
+ compressionRatio?: string;
227
+ };
228
+ /** Processing performance */
229
+ processing: {
230
+ timeMs: string;
231
+ throughputMBps?: string;
232
+ fromCache?: boolean;
233
+ };
234
+ /** Format-specific options */
235
+ jpegOptions?: object;
236
+ pngOptions?: object;
237
+ tiffOptions?: object;
238
+ webpOptions?: object;
239
+ avifOptions?: object;
240
+ /** Format type */
241
+ format?: string;
242
+ };
243
+ }
244
+
245
+ export interface LibRawImageConversionOptions {
246
+ /** Target width (maintains aspect ratio if height not specified) */
247
+ width?: number;
248
+ /** Target height (maintains aspect ratio if width not specified) */
249
+ height?: number;
250
+ /** Output color space */
251
+ colorSpace?: 'srgb' | 'rec2020' | 'p3' | 'cmyk';
252
+ /** Enable fast mode for better performance */
253
+ fastMode?: boolean;
254
+ }
255
+
256
+ export interface LibRawPNGOptions extends LibRawImageConversionOptions {
257
+ /** PNG compression level (0-9) */
258
+ compressionLevel?: number;
259
+ /** Use progressive PNG */
260
+ progressive?: boolean;
261
+ }
262
+
263
+ export interface LibRawTIFFOptions extends LibRawImageConversionOptions {
264
+ /** TIFF compression type */
265
+ compression?: 'none' | 'lzw' | 'jpeg' | 'zip';
266
+ /** JPEG quality when using JPEG compression */
267
+ quality?: number;
268
+ /** Create pyramidal TIFF */
269
+ pyramid?: boolean;
270
+ }
271
+
272
+ export interface LibRawWebPOptions extends LibRawImageConversionOptions {
273
+ /** WebP quality (1-100) */
274
+ quality?: number;
275
+ /** Use lossless WebP */
276
+ lossless?: boolean;
277
+ /** Encoding effort (0-6) */
278
+ effort?: number;
279
+ }
280
+
281
+ export interface LibRawAVIFOptions extends LibRawImageConversionOptions {
282
+ /** AVIF quality (1-100) */
283
+ quality?: number;
284
+ /** Use lossless AVIF */
285
+ lossless?: boolean;
286
+ /** Encoding effort (0-9) */
287
+ effort?: number;
288
+ }
289
+
290
+ export interface LibRawThumbnailJPEGOptions {
291
+ /** JPEG quality (1-100) */
292
+ quality?: number;
293
+ /** Maximum dimension size */
294
+ maxSize?: number;
295
+ }
296
+
297
+ export interface LibRawJPEGResult {
298
+ /** Conversion success status */
299
+ success: boolean;
300
+ /** Output file path */
301
+ outputPath: string;
302
+ /** Conversion metadata */
303
+ metadata: {
304
+ /** Original image dimensions */
305
+ originalDimensions: {
306
+ width: number;
307
+ height: number;
308
+ };
309
+ /** Output image dimensions */
310
+ outputDimensions: {
311
+ width: number;
312
+ height: number;
313
+ };
314
+ /** File size information */
315
+ fileSize: {
316
+ original: number;
317
+ compressed: number;
318
+ compressionRatio: string;
319
+ };
320
+ /** Processing performance */
321
+ processing: {
322
+ timeMs: string;
323
+ throughputMBps: string;
324
+ };
325
+ /** Applied JPEG options */
326
+ jpegOptions: object;
327
+ };
328
+ }
329
+
330
+ export interface LibRawBatchResult {
331
+ /** Successfully processed files */
332
+ successful: Array<{
333
+ input: string;
334
+ output: string;
335
+ result: LibRawJPEGResult;
336
+ }>;
337
+ /** Failed files */
338
+ failed: Array<{
339
+ input: string;
340
+ error: string;
341
+ }>;
342
+ /** Processing summary */
343
+ summary: {
344
+ total: number;
345
+ processed: number;
346
+ errors: number;
347
+ totalProcessingTime: number;
348
+ averageCompressionRatio: string;
349
+ totalOriginalSize: number;
350
+ totalCompressedSize: number;
351
+ averageProcessingTimePerFile: string;
352
+ };
353
+ }
354
+
355
+ export interface LibRawOptimalSettings {
356
+ /** Recommended JPEG settings */
357
+ recommended: LibRawJPEGOptions & {
358
+ reasoning: string[];
359
+ };
360
+ /** Image analysis results */
361
+ imageAnalysis: {
362
+ dimensions: {
363
+ width: number;
364
+ height: number;
365
+ area: number;
366
+ };
367
+ category: 'high-resolution' | 'medium-resolution' | 'low-resolution';
368
+ camera: {
369
+ make?: string;
370
+ model?: string;
371
+ };
372
+ };
373
+ }
374
+
375
+ export class LibRaw {
376
+ constructor();
377
+
378
+ // ============== FILE OPERATIONS ==============
379
+ /**
380
+ * Load RAW image from file
381
+ * @param filename Path to RAW image file
382
+ */
383
+ loadFile(filename: string): Promise<boolean>;
384
+
385
+ /**
386
+ * Load RAW image from buffer
387
+ * @param buffer Binary data buffer containing RAW image
388
+ */
389
+ loadBuffer(buffer: Buffer): Promise<boolean>;
390
+
391
+ /**
392
+ * Close current image and free resources
393
+ */
394
+ close(): Promise<boolean>;
395
+
396
+ // ============== METADATA & INFORMATION ==============
397
+ /**
398
+ * Get basic image metadata and EXIF information
399
+ */
400
+ getMetadata(): Promise<LibRawMetadata>;
401
+
402
+ /**
403
+ * Get image size and margin information
404
+ */
405
+ getImageSize(): Promise<LibRawImageSize>;
406
+
407
+ /**
408
+ * Get advanced metadata including color matrices
409
+ */
410
+ getAdvancedMetadata(): Promise<LibRawAdvancedMetadata>;
411
+
412
+ /**
413
+ * Get lens information from EXIF data
414
+ */
415
+ getLensInfo(): Promise<LibRawLensInfo>;
416
+
417
+ /**
418
+ * Get color space and sensor information
419
+ */
420
+ getColorInfo(): Promise<LibRawColorInfo>;
421
+
422
+ // ============== IMAGE PROCESSING ==============
423
+ /**
424
+ * Unpack thumbnail from RAW file
425
+ */
426
+ unpackThumbnail(): Promise<boolean>;
427
+
428
+ /**
429
+ * Process RAW image with current settings
430
+ */
431
+ processImage(): Promise<boolean>;
432
+
433
+ /**
434
+ * Subtract black level from image data
435
+ */
436
+ subtractBlack(): Promise<boolean>;
437
+
438
+ /**
439
+ * Convert RAW data to RGB image
440
+ */
441
+ raw2Image(): Promise<boolean>;
442
+
443
+ /**
444
+ * Adjust image maximum values
445
+ */
446
+ adjustMaximum(): Promise<boolean>;
447
+
448
+ // ============== MEMORY IMAGE CREATION ==============
449
+ /**
450
+ * Create processed image in memory
451
+ */
452
+ createMemoryImage(): Promise<LibRawImageData>;
453
+
454
+ /**
455
+ * Create thumbnail image in memory
456
+ */
457
+ createMemoryThumbnail(): Promise<LibRawImageData>;
458
+
459
+ // ============== FILE WRITERS ==============
460
+ /**
461
+ * Write processed image as PPM file
462
+ * @param filename Output PPM file path
463
+ */
464
+ writePPM(filename: string): Promise<boolean>;
465
+
466
+ /**
467
+ * Write processed image as TIFF file
468
+ * @param filename Output TIFF file path
469
+ */
470
+ writeTIFF(filename: string): Promise<boolean>;
471
+
472
+ /**
473
+ * Write thumbnail as JPEG file
474
+ * @param filename Output JPEG file path
475
+ */
476
+ writeThumbnail(filename: string): Promise<boolean>;
477
+
478
+ // ============== CONFIGURATION & SETTINGS ==============
479
+ /**
480
+ * Set output processing parameters
481
+ * @param params Output parameters configuration
482
+ */
483
+ setOutputParams(params: LibRawOutputParams): Promise<boolean>;
484
+
485
+ /**
486
+ * Get current output processing parameters
487
+ */
488
+ getOutputParams(): Promise<LibRawOutputParams>;
489
+
490
+ // ============== UTILITY FUNCTIONS ==============
491
+ /**
492
+ * Check if image uses floating point values
493
+ */
494
+ isFloatingPoint(): Promise<boolean>;
495
+
496
+ /**
497
+ * Check if image is from Fuji camera and rotated
498
+ */
499
+ isFujiRotated(): Promise<boolean>;
500
+
501
+ /**
502
+ * Check if image is sRAW format
503
+ */
504
+ isSRAW(): Promise<boolean>;
505
+
506
+ /**
507
+ * Check if file contains JPEG thumbnail
508
+ */
509
+ isJPEGThumb(): Promise<boolean>;
510
+
511
+ /**
512
+ * Get current error count
513
+ */
514
+ errorCount(): Promise<number>;
515
+
516
+ // ============== MEMORY STREAM OPERATIONS (NEW FEATURE) ==============
517
+ /**
518
+ * Create processed image as JPEG buffer in memory
519
+ * @param options JPEG conversion options
520
+ */
521
+ createJPEGBuffer(options?: LibRawJPEGOptions): Promise<LibRawBufferResult>;
522
+
523
+ /**
524
+ * Create processed image as PNG buffer in memory
525
+ * @param options PNG conversion options
526
+ */
527
+ createPNGBuffer(options?: LibRawPNGOptions): Promise<LibRawBufferResult>;
528
+
529
+ /**
530
+ * Create processed image as TIFF buffer in memory
531
+ * @param options TIFF conversion options
532
+ */
533
+ createTIFFBuffer(options?: LibRawTIFFOptions): Promise<LibRawBufferResult>;
534
+
535
+ /**
536
+ * Create processed image as WebP buffer in memory
537
+ * @param options WebP conversion options
538
+ */
539
+ createWebPBuffer(options?: LibRawWebPOptions): Promise<LibRawBufferResult>;
540
+
541
+ /**
542
+ * Create processed image as AVIF buffer in memory
543
+ * @param options AVIF conversion options
544
+ */
545
+ createAVIFBuffer(options?: LibRawAVIFOptions): Promise<LibRawBufferResult>;
546
+
547
+ /**
548
+ * Create raw PPM buffer from processed image data
549
+ */
550
+ createPPMBuffer(): Promise<LibRawBufferResult>;
551
+
552
+ /**
553
+ * Create thumbnail as JPEG buffer in memory
554
+ * @param options JPEG options for thumbnail
555
+ */
556
+ createThumbnailJPEGBuffer(options?: LibRawThumbnailJPEGOptions): Promise<LibRawBufferResult>;
557
+
558
+ // ============== JPEG CONVERSION (NEW FEATURE) ==============
559
+ /**
560
+ * Convert RAW to JPEG with advanced options
561
+ * @param outputPath Output JPEG file path
562
+ * @param options JPEG conversion options
563
+ */
564
+ convertToJPEG(outputPath: string, options?: LibRawJPEGOptions): Promise<LibRawJPEGResult>;
565
+
566
+ /**
567
+ * Batch convert multiple RAW files to JPEG
568
+ * @param inputPaths Array of input RAW file paths
569
+ * @param outputDir Output directory for JPEG files
570
+ * @param options JPEG conversion options
571
+ */
572
+ batchConvertToJPEG(inputPaths: string[], outputDir: string, options?: LibRawJPEGOptions): Promise<LibRawBatchResult>;
573
+
574
+ /**
575
+ * Get optimal JPEG conversion settings based on image analysis
576
+ * @param analysisOptions Options for image analysis
577
+ */
578
+ getOptimalJPEGSettings(analysisOptions?: { usage?: 'web' | 'print' | 'archive' }): Promise<LibRawOptimalSettings>;
579
+
580
+ /**
581
+ * High-performance JPEG conversion with minimal processing for speed
582
+ * @param outputPath Output JPEG file path
583
+ * @param options Speed-optimized JPEG options
584
+ */
585
+ convertToJPEGFast(outputPath: string, options?: LibRawJPEGOptions): Promise<LibRawJPEGResult>;
586
+
587
+ /**
588
+ * Create multiple JPEG sizes from single RAW (thumbnail, web, full)
589
+ * @param baseOutputPath Base output path (without extension)
590
+ * @param options Multi-size options
591
+ */
592
+ convertToJPEGMultiSize(baseOutputPath: string, options?: {
593
+ sizes?: Array<{
594
+ name: string;
595
+ width?: number;
596
+ height?: number;
597
+ quality?: number;
598
+ progressive?: boolean;
599
+ mozjpeg?: boolean;
600
+ chromaSubsampling?: string;
601
+ effort?: number;
602
+ }>;
603
+ }): Promise<{
604
+ success: boolean;
605
+ sizes: Record<string, {
606
+ name: string;
607
+ outputPath: string;
608
+ dimensions: { width: number; height: number };
609
+ fileSize: number;
610
+ processingTime: number;
611
+ config: any;
612
+ }>;
613
+ originalDimensions: { width: number; height: number };
614
+ totalProcessingTime: number;
615
+ averageTimePerSize: string;
616
+ }>;
617
+
618
+ // ============== STATIC METHODS ==============
619
+ /**
620
+ * Get LibRaw library version
621
+ */
622
+ static getVersion(): string;
623
+
624
+ /**
625
+ * Get LibRaw library capabilities bitmask
626
+ */
627
+ static getCapabilities(): number;
628
+
629
+ /**
630
+ * Get list of supported camera models
631
+ */
632
+ static getCameraList(): string[];
633
+
634
+ /**
635
+ * Get count of supported camera models
636
+ */
637
+ static getCameraCount(): number;
638
+ }
639
+
640
+ export = LibRaw;
641
+ }