lightdrift-libraw 1.0.0-alpha.1 → 1.0.0-alpha.3

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
@@ -157,6 +157,221 @@ declare module 'libraw' {
157
157
  data: Buffer;
158
158
  }
159
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
+
160
375
  export class LibRaw {
161
376
  constructor();
162
377
 
@@ -298,6 +513,108 @@ declare module 'libraw' {
298
513
  */
299
514
  errorCount(): Promise<number>;
300
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
+
301
618
  // ============== STATIC METHODS ==============
302
619
  /**
303
620
  * Get LibRaw library version