lightdrift-libraw 1.0.0-alpha.2 → 1.0.0-alpha.4

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/lib/index.d.ts CHANGED
@@ -3,500 +3,645 @@
3
3
  * Provides type-safe access to LibRaw functionality for RAW image processing
4
4
  */
5
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 LibRawJPEGResult {
201
- /** Conversion success status */
202
- success: boolean;
203
- /** Output file path */
204
- outputPath: string;
205
- /** Conversion 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
- /** File size information */
218
- fileSize: {
219
- original: number;
220
- compressed: number;
221
- compressionRatio: string;
222
- };
223
- /** Processing performance */
224
- processing: {
225
- timeMs: string;
226
- throughputMBps: string;
227
- };
228
- /** Applied JPEG options */
229
- jpegOptions: object;
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;
230
210
  };
231
- }
232
-
233
- export interface LibRawBatchResult {
234
- /** Successfully processed files */
235
- successful: Array<{
236
- input: string;
237
- output: string;
238
- result: LibRawJPEGResult;
239
- }>;
240
- /** Failed files */
241
- failed: Array<{
242
- input: string;
243
- error: string;
244
- }>;
245
- /** Processing summary */
246
- summary: {
247
- total: number;
248
- processed: number;
249
- errors: number;
250
- totalProcessingTime: number;
251
- averageCompressionRatio: string;
252
- totalOriginalSize: number;
253
- totalCompressedSize: number;
254
- averageProcessingTimePerFile: string;
211
+ /** Output image dimensions */
212
+ outputDimensions?: {
213
+ width: number;
214
+ height: number;
255
215
  };
256
- }
257
-
258
- export interface LibRawOptimalSettings {
259
- /** Recommended JPEG settings */
260
- recommended: LibRawJPEGOptions & {
261
- reasoning: string[];
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;
262
307
  };
263
- /** Image analysis results */
264
- imageAnalysis: {
265
- dimensions: {
266
- width: number;
267
- height: number;
268
- area: number;
269
- };
270
- category: 'high-resolution' | 'medium-resolution' | 'low-resolution';
271
- camera: {
272
- make?: string;
273
- model?: string;
274
- };
308
+ /** Output image dimensions */
309
+ outputDimensions: {
310
+ width: number;
311
+ height: number;
275
312
  };
276
- }
277
-
278
- export class LibRaw {
279
- constructor();
280
-
281
- // ============== FILE OPERATIONS ==============
282
- /**
283
- * Load RAW image from file
284
- * @param filename Path to RAW image file
285
- */
286
- loadFile(filename: string): Promise<boolean>;
287
-
288
- /**
289
- * Load RAW image from buffer
290
- * @param buffer Binary data buffer containing RAW image
291
- */
292
- loadBuffer(buffer: Buffer): Promise<boolean>;
293
-
294
- /**
295
- * Close current image and free resources
296
- */
297
- close(): Promise<boolean>;
298
-
299
- // ============== METADATA & INFORMATION ==============
300
- /**
301
- * Get basic image metadata and EXIF information
302
- */
303
- getMetadata(): Promise<LibRawMetadata>;
304
-
305
- /**
306
- * Get image size and margin information
307
- */
308
- getImageSize(): Promise<LibRawImageSize>;
309
-
310
- /**
311
- * Get advanced metadata including color matrices
312
- */
313
- getAdvancedMetadata(): Promise<LibRawAdvancedMetadata>;
314
-
315
- /**
316
- * Get lens information from EXIF data
317
- */
318
- getLensInfo(): Promise<LibRawLensInfo>;
319
-
320
- /**
321
- * Get color space and sensor information
322
- */
323
- getColorInfo(): Promise<LibRawColorInfo>;
324
-
325
- // ============== IMAGE PROCESSING ==============
326
- /**
327
- * Unpack thumbnail from RAW file
328
- */
329
- unpackThumbnail(): Promise<boolean>;
330
-
331
- /**
332
- * Process RAW image with current settings
333
- */
334
- processImage(): Promise<boolean>;
335
-
336
- /**
337
- * Subtract black level from image data
338
- */
339
- subtractBlack(): Promise<boolean>;
340
-
341
- /**
342
- * Convert RAW data to RGB image
343
- */
344
- raw2Image(): Promise<boolean>;
345
-
346
- /**
347
- * Adjust image maximum values
348
- */
349
- adjustMaximum(): Promise<boolean>;
350
-
351
- // ============== MEMORY IMAGE CREATION ==============
352
- /**
353
- * Create processed image in memory
354
- */
355
- createMemoryImage(): Promise<LibRawImageData>;
356
-
357
- /**
358
- * Create thumbnail image in memory
359
- */
360
- createMemoryThumbnail(): Promise<LibRawImageData>;
361
-
362
- // ============== FILE WRITERS ==============
363
- /**
364
- * Write processed image as PPM file
365
- * @param filename Output PPM file path
366
- */
367
- writePPM(filename: string): Promise<boolean>;
368
-
369
- /**
370
- * Write processed image as TIFF file
371
- * @param filename Output TIFF file path
372
- */
373
- writeTIFF(filename: string): Promise<boolean>;
374
-
375
- /**
376
- * Write thumbnail as JPEG file
377
- * @param filename Output JPEG file path
378
- */
379
- writeThumbnail(filename: string): Promise<boolean>;
380
-
381
- // ============== CONFIGURATION & SETTINGS ==============
382
- /**
383
- * Set output processing parameters
384
- * @param params Output parameters configuration
385
- */
386
- setOutputParams(params: LibRawOutputParams): Promise<boolean>;
387
-
388
- /**
389
- * Get current output processing parameters
390
- */
391
- getOutputParams(): Promise<LibRawOutputParams>;
392
-
393
- // ============== UTILITY FUNCTIONS ==============
394
- /**
395
- * Check if image uses floating point values
396
- */
397
- isFloatingPoint(): Promise<boolean>;
398
-
399
- /**
400
- * Check if image is from Fuji camera and rotated
401
- */
402
- isFujiRotated(): Promise<boolean>;
403
-
404
- /**
405
- * Check if image is sRAW format
406
- */
407
- isSRAW(): Promise<boolean>;
408
-
409
- /**
410
- * Check if file contains JPEG thumbnail
411
- */
412
- isJPEGThumb(): Promise<boolean>;
413
-
414
- /**
415
- * Get current error count
416
- */
417
- errorCount(): Promise<number>;
418
-
419
- // ============== JPEG CONVERSION (NEW FEATURE) ==============
420
- /**
421
- * Convert RAW to JPEG with advanced options
422
- * @param outputPath Output JPEG file path
423
- * @param options JPEG conversion options
424
- */
425
- convertToJPEG(outputPath: string, options?: LibRawJPEGOptions): Promise<LibRawJPEGResult>;
426
-
427
- /**
428
- * Batch convert multiple RAW files to JPEG
429
- * @param inputPaths Array of input RAW file paths
430
- * @param outputDir Output directory for JPEG files
431
- * @param options JPEG conversion options
432
- */
433
- batchConvertToJPEG(inputPaths: string[], outputDir: string, options?: LibRawJPEGOptions): Promise<LibRawBatchResult>;
434
-
435
- /**
436
- * Get optimal JPEG conversion settings based on image analysis
437
- * @param analysisOptions Options for image analysis
438
- */
439
- getOptimalJPEGSettings(analysisOptions?: { usage?: 'web' | 'print' | 'archive' }): Promise<LibRawOptimalSettings>;
440
-
441
- /**
442
- * High-performance JPEG conversion with minimal processing for speed
443
- * @param outputPath Output JPEG file path
444
- * @param options Speed-optimized JPEG options
445
- */
446
- convertToJPEGFast(outputPath: string, options?: LibRawJPEGOptions): Promise<LibRawJPEGResult>;
447
-
448
- /**
449
- * Create multiple JPEG sizes from single RAW (thumbnail, web, full)
450
- * @param baseOutputPath Base output path (without extension)
451
- * @param options Multi-size options
452
- */
453
- convertToJPEGMultiSize(baseOutputPath: string, options?: {
454
- sizes?: Array<{
455
- name: string;
456
- width?: number;
457
- height?: number;
458
- quality?: number;
459
- progressive?: boolean;
460
- mozjpeg?: boolean;
461
- chromaSubsampling?: string;
462
- effort?: number;
463
- }>;
464
- }): Promise<{
465
- success: boolean;
466
- sizes: Record<string, {
467
- name: string;
468
- outputPath: string;
469
- dimensions: { width: number; height: number };
470
- fileSize: number;
471
- processingTime: number;
472
- config: any;
473
- }>;
474
- originalDimensions: { width: number; height: number };
475
- totalProcessingTime: number;
476
- averageTimePerSize: string;
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;
477
601
  }>;
478
-
479
- // ============== STATIC METHODS ==============
480
- /**
481
- * Get LibRaw library version
482
- */
483
- static getVersion(): string;
484
-
485
- /**
486
- * Get LibRaw library capabilities bitmask
487
- */
488
- static getCapabilities(): number;
489
-
490
- /**
491
- * Get list of supported camera models
492
- */
493
- static getCameraList(): string[];
494
-
495
- /**
496
- * Get count of supported camera models
497
- */
498
- static getCameraCount(): number;
499
- }
500
-
501
- export = LibRaw;
502
- }
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;