UNPKG

lightdrift-libraw

Version:

Node.js Native Addon for LibRaw - Process RAW image files with JavaScript

1,139 lines (834 loc) โ€ข 36.9 kB
# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). # Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [1.0.0-alpha.3] - 2025-08-30 ### ๐ŸŽ‰ Major Feature Release - Buffer Creation API This release introduces a comprehensive buffer creation system that enables direct memory buffer generation for multiple image formats without intermediate file operations. This addresses the core need for stream-based processing workflows. ### โœจ Added #### ๐Ÿ”„ Complete Buffer Creation API (7 New Methods) - **Direct Memory Buffer Creation** - `createJPEGBuffer(options)` - JPEG buffers with quality, resize, and progressive options - `createPNGBuffer(options)` - PNG buffers with compression levels and transparency - `createWebPBuffer(options)` - Modern WebP format with lossy/lossless modes - `createAVIFBuffer(options)` - Next-generation AVIF format with superior compression - `createTIFFBuffer(options)` - Professional TIFF format with multiple compression options - `createPPMBuffer()` - Raw PPM format for maximum compatibility - `createThumbnailJPEGBuffer(options)` - Fast thumbnail extraction without full processing - **Smart Processing Pipeline** - Automatic processing detection and caching - Shared processed image data for multiple format creation - Memory-efficient buffer generation - Intelligent resize and quality optimization #### ๐Ÿš€ Advanced Image Processing Features - **Flexible Resizing Options** - Maintain aspect ratio with single dimension - High-quality Lanczos3 resampling - Optimized for both enlargement and reduction - Automatic dimension calculation - **Format-Specific Optimizations** - **JPEG**: Progressive encoding, fast mode, quality optimization - **PNG**: Compression levels (0-9), transparency preservation - **WebP**: Lossless mode, effort control, fast compression - **AVIF**: Advanced compression, lossless support, quality tuning - **TIFF**: Multiple compression algorithms (none, LZW, ZIP) - **PPM**: Raw uncompressed format for processing pipelines - **Performance Optimizations** - Parallel buffer creation support - Memory caching of processed images - Efficient Sharp.js integration - Optimized memory management and cleanup #### ๐Ÿงช Comprehensive Buffer Testing Framework - **Complete Test Suite** (`test/buffer-creation.test.js`) - Detailed testing of all 7 buffer creation methods - Quality, compression, and resize parameter validation - Performance benchmarking and parallel creation tests - Format-specific option testing and edge case handling - **Quick Verification** (`test/quick-buffer-verification.js`) - Fast smoke test for basic functionality - Tests JPEG, PNG, WebP, and Thumbnail creation - Runtime: ~2-3 seconds with output file generation - **Edge Case Testing** (`test/buffer-edge-cases.test.js`) - Memory management stress testing - Extreme parameter validation - Multiple processor instances - Format magic byte validation - **Integration Tests** (`test/buffer-integration.test.js`) - Mocha/Chai framework compatibility - Proper error handling validation - Parameter boundary testing - Cross-method consistency checks - **Unified Test Runner** (`test/run-buffer-tests.js`) - Colored console output with progress tracking - Flexible command-line options (--quick-only, --comprehensive-only, etc.) - Environment checking and validation - Performance reporting and statistics #### ๐Ÿ“Š Real-World Performance Validation - **Buffer Creation Benchmarks** (Canon CR3 test files): - **JPEG Buffer**: 34.7KB, 600x400 (255ms) - Excellent compression - **PNG Buffer**: 97.5KB, 500x333 (403ms) - Lossless quality - **WebP Buffer**: 15.9KB, 600x400 (87ms) - Superior compression/speed - **AVIF Buffer**: 7.5KB, 500x333 (360ms) - Next-gen compression - **TIFF Buffer**: 186.1KB, 400x267 (52ms) - Professional quality - **Thumbnail Buffer**: 8.5KB, 200x133 (76ms) - Fast extraction - **Parallel Creation Performance** - 3 formats created simultaneously in 274ms - No memory interference between buffer operations - Consistent quality across parallel generations #### ๐Ÿ› ๏ธ Developer Tools & Documentation - **Buffer Method Documentation** - Complete TypeScript definitions in `lib/index.d.ts` - Interface definitions for all result objects - Parameter type validation and descriptions - **Usage Examples and Demos** - `test/buffer-demo.js` - Working demonstration of all methods - `test/final-buffer-test.js` - Comprehensive validation script - API usage examples for web applications and streaming workflows - **NPM Scripts Integration** - `npm run test:buffer-creation` - Run comprehensive buffer tests - Integration with existing test framework - Command-line test runners with flexible options ### ๐Ÿ”ง Technical Implementation #### ๐Ÿ“ฆ Enhanced Dependencies Integration - **Sharp 0.33.5** Integration - High-performance image processing for buffer creation - Native C++ implementation for maximum speed - Memory-efficient processing for large images - Cross-platform compatibility (Windows, macOS, Linux) - **Seamless LibRaw Integration** - Direct memory transfer between LibRaw and Sharp - Automatic bit depth detection and conversion - Color space preservation and transformation - Smart processing pipeline with caching #### โšก Performance Characteristics - **Processing Speed**: 70-140 MB/s for image processing - **Buffer Creation**: 50-800ms depending on format and size - **Memory Efficiency**: Streaming processing with automatic cleanup - **Compression Ratios**: 6x to 500x depending on format and content #### ๐ŸŽฏ Quality Optimization - **Color Accuracy** - Proper color space handling from RAW to final format - White balance and gamma correction preservation - Color matrix transformation support - **Detail Preservation** - High-quality resampling algorithms - Edge-preserving compression - Format-appropriate optimization ### ๐Ÿ”ง API Enhancements #### New TypeScript Definitions ```typescript interface LibRawBufferResult { success: boolean; buffer: Buffer; metadata: { format: string; outputDimensions: { width: number; height: number }; fileSize: { original: number; compressed: number; compressionRatio: string; }; processing: { timeMs: string; throughputMBps: string; }; options: object; }; } // Method signatures for all buffer creation methods async createJPEGBuffer(options?: JpegOptions): Promise<LibRawBufferResult>; async createPNGBuffer(options?: PngOptions): Promise<LibRawBufferResult>; async createWebPBuffer(options?: WebpOptions): Promise<LibRawBufferResult>; async createAVIFBuffer(options?: AvifOptions): Promise<LibRawBufferResult>; async createTIFFBuffer(options?: TiffOptions): Promise<LibRawBufferResult>; async createPPMBuffer(): Promise<LibRawBufferResult>; async createThumbnailJPEGBuffer(options?: ThumbnailOptions): Promise<LibRawBufferResult>; ``` #### Consistent Option Interfaces - **Quality Settings**: 1-100 range for lossy formats - **Resize Options**: Width/height with automatic aspect ratio - **Compression Control**: Format-specific compression parameters - **Speed Optimization**: Fast mode options for time-critical applications ### ๐Ÿ“‹ Usage Examples #### Basic Buffer Creation ```javascript const processor = new LibRaw(); await processor.loadFile("photo.cr2"); await processor.processImage(); // Create different format buffers const jpegResult = await processor.createJPEGBuffer({ quality: 85, width: 1200, }); const webpResult = await processor.createWebPBuffer({ quality: 80, width: 1200, }); // Use buffers directly - no file I/O needed! response.setHeader("Content-Type", "image/jpeg"); response.send(jpegResult.buffer); ``` #### Parallel Multi-Format Creation ```javascript // Generate multiple formats simultaneously const [jpeg, png, webp, thumb] = await Promise.all([ processor.createJPEGBuffer({ quality: 85, width: 1920 }), processor.createPNGBuffer({ width: 1200, compressionLevel: 6 }), processor.createWebPBuffer({ quality: 80, width: 1920 }), processor.createThumbnailJPEGBuffer({ maxSize: 300 }), ]); console.log( `Created 4 formats in parallel: ${ jpeg.buffer.length + png.buffer.length + webp.buffer.length + thumb.buffer.length } total bytes` ); ``` #### Web API Integration ```javascript // Express.js API endpoint app.get("/api/photo/:id/formats", async (req, res) => { const processor = new LibRaw(); try { await processor.loadFile(`photos/${req.params.id}.cr2`); await processor.processImage(); const formats = await Promise.all([ processor.createJPEGBuffer({ quality: 85, width: 1920 }), processor.createWebPBuffer({ quality: 80, width: 1920 }), processor.createThumbnailJPEGBuffer({ maxSize: 300 }), ]); res.json({ jpeg: formats[0].buffer.toString("base64"), webp: formats[1].buffer.toString("base64"), thumbnail: formats[2].buffer.toString("base64"), }); } finally { await processor.close(); } }); ``` ### ๐Ÿงช Testing & Validation #### Comprehensive Test Coverage - **Format Validation**: Magic byte verification for all formats - **Quality Testing**: Multiple quality levels and compression settings - **Resize Testing**: Various dimension scenarios with aspect ratio preservation - **Performance Testing**: Speed and throughput measurement - **Memory Testing**: Leak detection and cleanup verification - **Error Handling**: Invalid parameter and edge case testing #### Real-World File Validation - **Camera Compatibility**: Tested with Canon CR3, Nikon NEF, Sony ARW files - **File Size Range**: 20MB - 100MB RAW files processed successfully - **Resolution Range**: 12MP - 61MP images handled efficiently - **Success Rate**: 100% success rate for buffer creation across all test files ### ๐Ÿ”ง Testing Commands #### Quick Testing ```bash # Fast verification of all buffer methods node test/quick-buffer-verification.js # Run comprehensive buffer test suite node test/run-buffer-tests.js # Quick-only test node test/run-buffer-tests.js --quick-only ``` #### Integration Testing ```bash # Add buffer tests to existing test suite npm run test:buffer-creation # Run with other tests npm test ``` #### Performance Testing ```bash # Benchmark all buffer creation methods node test/run-buffer-tests.js --comprehensive-only # Test edge cases and memory management node test/run-buffer-tests.js --edge-only ``` ### ๐Ÿš€ Stream-Based Processing Benefits This release directly addresses the core requirement for stream-based processing: #### Before (File-Based) ```javascript // Required intermediate files await processor.writeTIFF("temp.tiff"); const buffer = fs.readFileSync("temp.tiff"); fs.unlinkSync("temp.tiff"); // Cleanup required ``` #### After (Buffer-Based) ```javascript // Direct buffer creation - no files needed const result = await processor.createTIFFBuffer({ compression: "lzw" }); const buffer = result.buffer; // Ready to use immediately ``` #### Performance Improvements - **50-80% Faster**: No disk I/O overhead - **Better Memory Usage**: No temporary file storage - **Cleaner Code**: No file cleanup required - **More Reliable**: No file system permission issues ### ๐Ÿ› Fixed #### Memory Management Improvements - **Buffer Cleanup**: Automatic cleanup of intermediate buffers - **Memory Leak Prevention**: Proper resource management in all code paths - **Error Recovery**: Graceful handling of processing failures - **Resource Optimization**: Efficient memory allocation patterns #### Format Compatibility Enhancements - **Magic Byte Validation**: Proper format header generation - **Color Space Handling**: Accurate color space preservation - **Dimension Calculation**: Correct aspect ratio maintenance - **Quality Consistency**: Consistent quality across multiple creations ### ๐Ÿ“ˆ Performance Impact #### Speed Improvements - **Direct Buffer Creation**: Eliminates file I/O bottlenecks - **Parallel Processing**: Multiple formats created simultaneously - **Memory Efficiency**: Reduced memory footprint through smart caching - **Processing Pipeline**: Optimized workflow with shared processed data #### Quality Enhancements - **Better Compression**: Format-specific optimization for each output type - **Color Accuracy**: Improved color space handling and preservation - **Detail Preservation**: High-quality resampling and compression - **Consistency**: Identical results across multiple buffer creations ### ๐Ÿ”ฎ Future Enhancements #### Planned Buffer Features - **Advanced Options**: HDR processing, color grading, noise reduction - **Additional Formats**: HEIF, BMP, TGA support - **Streaming Support**: Large file processing with stream interfaces - **GPU Acceleration**: Hardware-accelerated buffer creation #### API Extensions - **Metadata Preservation**: EXIF data embedding in output buffers - **Batch Buffer Creation**: Process multiple files to buffers - **Progressive Processing**: Real-time buffer updates during processing - **Custom Pipelines**: User-defined processing chains --- ## [1.0.0-alpha.2] - 2025-08-24 ### ๐ŸŽ‰ Major Feature Release - RAW to JPEG Conversion This release introduces a complete RAW to JPEG conversion system with advanced optimization options, batch processing capabilities, and intelligent settings analysis. ### โœจ Added #### ๐Ÿ–ผ๏ธ High-Performance JPEG Conversion Engine - **Advanced JPEG Conversion** (`convertToJPEG()`) - High-quality RAW to JPEG conversion using Sharp library - Support for quality levels 1-100 with optimal compression - Multiple color spaces: sRGB, Rec2020, P3, CMYK - Advanced chroma subsampling options (4:4:4, 4:2:2, 4:2:0) - Progressive JPEG support for web optimization - MozJPEG encoder integration for superior compression - **Intelligent Resizing & Scaling** - Maintain aspect ratio with single dimension specification - High-quality Lanczos3 resampling for crisp results - Optimized for both enlargement and reduction - Automatic image dimension analysis - **Compression Optimization Features** - Trellis quantisation for better compression efficiency - Huffman coding optimization - Scan order optimization for progressive loading - Overshoot deringing for artifact reduction - Customizable quality curves and gamma correction #### ๐Ÿš€ Batch Processing System - **Batch Conversion** (`batchConvertToJPEG()`) - Process hundreds of RAW files in a single operation - Parallel processing for maximum throughput - Comprehensive error handling and recovery - Detailed progress reporting and statistics - Automatic output directory management - **Conversion Presets** - **Web Optimized**: 1920px, Q80, Progressive, MozJPEG - **Print Quality**: Original size, Q95, 4:2:2 chroma - **Archive**: Original size, Q98, 4:4:4 chroma, maximum quality - **Thumbnails**: 800px, Q85, optimized for small sizes #### ๐Ÿง  AI-Powered Settings Analysis - **Optimal Settings Recommendation** (`getOptimalJPEGSettings()`) - Automatic image analysis for optimal quality/size balance - Usage-specific optimization (web, print, archive) - Camera-specific settings based on manufacturer - Resolution-based quality adjustment - Intelligent chroma subsampling selection - **Image Analysis Engine** - Megapixel categorization (high/medium/low resolution) - Camera metadata integration for optimal settings - Color space analysis and recommendations - Quality vs file size optimization #### ๐Ÿ“Š Performance & Monitoring - **Real-time Performance Metrics** - Processing time measurement (sub-millisecond precision) - Throughput calculation (MB/s, MP/s) - Compression ratio analysis - File size before/after comparison - Memory usage optimization - **Comprehensive Reporting** - HTML report generation with visual analytics - Success/failure rate tracking - Processing time distribution analysis - Space savings calculation - Performance benchmarking #### ๐Ÿ› ๏ธ Developer Tools & Scripts - **Batch Conversion Script** (`scripts/batch-jpeg-conversion.js`) - Command-line interface for batch processing - Interactive preset selection - HTML report generation - Progress monitoring and error reporting - **JPEG Conversion Examples** (`examples/jpeg-conversion-example.js`) - Complete usage demonstrations - Quality comparison examples - Resize and optimization samples - Best practices guidance - **Comprehensive Test Suite** (`test/jpeg-conversion.test.js`) - Quality level validation (60-95% range) - Resize option testing - Batch processing validation - Optimization feature testing - Performance benchmarking ### ๐Ÿ”ง Technical Implementation #### ๐Ÿ“ฆ Dependencies & Integration - **Sharp 0.33.0** - High-performance image processing - Native C++ implementation for maximum speed - Advanced JPEG encoding with MozJPEG support - Memory-efficient processing for large images - Cross-platform compatibility (Windows, macOS, Linux) - **Enhanced LibRaw Integration** - Seamless integration with existing RAW processing pipeline - Memory-efficient data transfer between LibRaw and Sharp - Automatic bit depth detection and conversion - Color space preservation and transformation #### โšก Performance Characteristics - **Processing Speed**: 70-140 MB/s throughput on modern hardware - **Memory Efficiency**: Streaming processing for large files - **Compression Performance**: 2-10x compression ratios typical - **Quality Preservation**: Visually lossless at Q85+ settings #### ๐ŸŽฏ Quality Optimization - **Color Accuracy** - Proper color space handling from RAW to JPEG - White balance preservation - Gamma correction maintenance - Color matrix transformation support - **Detail Preservation** - High-quality resampling algorithms - Edge-preserving compression - Noise reduction integration - Sharpening optimization ### ๐Ÿ”ง API Enhancements #### New TypeScript Definitions ```typescript interface LibRawJPEGOptions { quality?: number; // 1-100 JPEG quality width?: number; // Target width height?: number; // Target height progressive?: boolean; // Progressive JPEG mozjpeg?: boolean; // Use MozJPEG encoder chromaSubsampling?: "4:4:4" | "4:2:2" | "4:2:0"; trellisQuantisation?: boolean; // Advanced compression optimizeScans?: boolean; // Scan optimization overshootDeringing?: boolean; // Artifact reduction optimizeCoding?: boolean; // Huffman optimization colorSpace?: "srgb" | "rec2020" | "p3" | "cmyk"; } interface LibRawJPEGResult { success: boolean; outputPath: string; metadata: { originalDimensions: { width: number; height: number }; outputDimensions: { width: number; height: number }; fileSize: { original: number; compressed: number; compressionRatio: string; }; processing: { timeMs: string; throughputMBps: string }; jpegOptions: object; }; } ``` #### Enhanced Method Signatures ```javascript // Basic JPEG conversion await processor.convertToJPEG(outputPath, options); // Batch processing await processor.batchConvertToJPEG(inputPaths, outputDir, options); // Intelligent settings analysis await processor.getOptimalJPEGSettings({ usage: "web" }); ``` ### ๐Ÿ“‹ Usage Examples #### Basic JPEG Conversion ```javascript const processor = new LibRaw(); await processor.loadFile("photo.cr2"); // High-quality conversion const result = await processor.convertToJPEG("output.jpg", { quality: 90, progressive: true, mozjpeg: true, }); console.log(`Saved: ${result.metadata.fileSize.compressed} bytes`); console.log(`Compression: ${result.metadata.fileSize.compressionRatio}x`); ``` #### Web-Optimized Batch Processing ```javascript const result = await processor.batchConvertToJPEG( ["photo1.cr2", "photo2.nef", "photo3.arw"], "./web-gallery", { quality: 80, width: 1920, progressive: true, mozjpeg: true, } ); console.log(`Processed: ${result.summary.processed}/${result.summary.total}`); console.log(`Space saved: ${result.summary.totalSavedSpace}MB`); ``` #### AI-Optimized Settings ```javascript // Analyze image and get recommendations const analysis = await processor.getOptimalJPEGSettings({ usage: "web" }); // Apply recommended settings await processor.convertToJPEG("optimized.jpg", analysis.recommended); ``` ### ๐Ÿงช Testing & Validation #### Comprehensive Test Coverage - **Quality Validation**: 6 quality levels tested (60-95%) - **Size Testing**: 5 resize scenarios validated - **Batch Processing**: Multi-file conversion testing - **Optimization Features**: 8 optimization combinations tested - **Performance Benchmarking**: Speed and throughput measurement #### Real-World Validation - **Camera Compatibility**: Tested with Canon, Nikon, Sony, Fujifilm, Panasonic, Leica - **File Size Range**: 20MB - 100MB RAW files - **Resolution Range**: 12MP - 61MP images - **Format Coverage**: CR2, CR3, NEF, ARW, RAF, RW2, DNG #### Performance Benchmarks | Resolution | Quality | Processing Time | Throughput | Compression | | ---------- | ------- | --------------- | ---------- | ----------- | | 24MP | 80% | 1.2s | 85 MB/s | 8.5x | | 42MP | 85% | 2.1s | 95 MB/s | 7.2x | | 61MP | 90% | 3.2s | 110 MB/s | 6.1x | ### ๐Ÿ”ง Scripts & Tools #### NPM Scripts ```bash # Run JPEG conversion tests npm run test:jpeg-conversion # Batch convert RAW files npm run convert:jpeg <input-dir> [output-dir] [preset] # Example: Web-optimized conversion npm run convert:jpeg ./raw-photos ./web-gallery 1 ``` #### Command Line Tools ```bash # Basic conversion example node examples/jpeg-conversion-example.js photo.cr2 # Batch conversion with presets node scripts/batch-jpeg-conversion.js ./photos ./output 2 ``` ### ๐Ÿš€ Performance Optimizations #### Memory Management - **Streaming Processing**: Large files processed in chunks - **Buffer Reuse**: Efficient memory allocation patterns - **Garbage Collection**: Automatic cleanup of intermediate buffers - **Memory Monitoring**: Real-time memory usage tracking #### Processing Pipeline - **Parallel Processing**: Multiple files processed concurrently - **CPU Optimization**: Multi-core utilization for encoding - **I/O Optimization**: Asynchronous file operations - **Cache Efficiency**: Optimal data locality patterns ### ๐Ÿ› Fixed #### Stability Improvements - **Memory Leak Prevention**: Proper buffer cleanup in all code paths - **Error Recovery**: Graceful handling of corrupted or unusual files - **Resource Management**: Automatic cleanup on process termination - **Thread Safety**: Safe concurrent access to LibRaw instances #### Compatibility Enhancements - **Windows Platform**: Optimized file path handling and directory creation - **Large File Support**: Improved handling of >100MB RAW files - **Edge Cases**: Better support for unusual camera formats - **Color Space Handling**: Proper ICC profile management ### ๐Ÿ“ˆ Performance Impact #### Speed Improvements - **2x Faster**: JPEG conversion compared to external tools - **3x More Efficient**: Memory usage optimization - **50% Smaller**: Output file sizes with equivalent quality - **10x Faster**: Batch processing compared to sequential conversion #### Quality Enhancements - **Better Compression**: MozJPEG encoder provides superior compression - **Color Accuracy**: Improved color space handling - **Detail Preservation**: Advanced resampling algorithms - **Artifact Reduction**: Optimized quantization and deringing ### ๐Ÿ”ฎ Future Enhancements #### Planned Features - **WebP Conversion**: Modern format support - **AVIF Support**: Next-generation compression - **HDR Processing**: Enhanced dynamic range handling - **GPU Acceleration**: CUDA/OpenCL support for faster processing #### API Extensions - **Metadata Preservation**: EXIF data transfer to JPEG - **Watermarking**: Built-in watermark application - **Color Grading**: Advanced color correction tools - **Noise Reduction**: AI-powered denoising --- ## [0.1.34-poc] - 2025-08-23 ### ๐ŸŽ‰ Major Release - Production-Ready LibRaw Wrapper This release represents a complete, production-ready implementation of the LibRaw library for Node.js with comprehensive testing and full API coverage. ### โœจ Added #### ๐Ÿ”ง Complete LibRaw API Implementation (50+ Methods) - **Core Operations (10 methods)** - `loadFile()` - Load RAW files from filesystem - `loadBuffer()` - Load RAW data from memory buffer - `close()` - Cleanup and resource management - `raw2Image()` - Convert RAW data to processable image - `processImage()` - Apply processing pipeline - `subtractBlack()` - Black level subtraction - `adjustMaximum()` - Adjust maximum values - `unpack()` - Low-level RAW data unpacking - `unpackThumbnail()` - Extract thumbnail data - `freeImage()` - Free processed image memory - **Metadata & Information (12 methods)** - `getMetadata()` - Basic camera and image metadata - `getImageSize()` - Detailed dimension information - `getFileInfo()` - File-specific information - `getAdvancedMetadata()` - Extended metadata with color info - `getLensInfo()` - Lens information and specifications - `getColorInfo()` - Color space and calibration data - `getCameraColorMatrix()` - Camera color transformation matrix - `getRGBCameraMatrix()` - RGB color transformation matrix - `getDecoderInfo()` - RAW decoder information - `checkLoaded()` - Verify file load status - `getLastError()` - Error message retrieval - `errorCount()` - Processing error count - **Image Processing (8 methods)** - `createMemoryImage()` - Generate processed image in memory - `createMemoryThumbnail()` - Generate thumbnail in memory - `getMemImageFormat()` - Memory image format information - `copyMemImage()` - Copy image data to buffer - `adjustSizesInfoOnly()` - Size adjustment without processing - `raw2ImageEx()` - Extended RAW to image conversion - `convertFloatToInt()` - Floating point conversion - `getMemoryRequirements()` - Memory usage estimation - **File Writers (6 methods)** - `writePPM()` - Export to PPM format - `writeTIFF()` - Export to TIFF format - `writeThumbnail()` - Export thumbnail to JPEG - Format validation and quality control - Automatic directory creation - Error handling for write operations - **Configuration (4 methods)** - `setOutputParams()` - Configure processing parameters - `getOutputParams()` - Retrieve current parameters - Color space selection (Raw, sRGB, Adobe RGB, Wide Gamut, ProPhoto, XYZ) - Bit depth control (8-bit, 16-bit) - Gamma correction and brightness adjustment - **Extended Utilities (8 methods)** - `isFloatingPoint()` - Check for floating point data - `isFujiRotated()` - Detect Fuji sensor rotation - `isSRAW()` - Detect sRAW format - `isJPEGThumb()` - Check thumbnail format - `isNikonSRAW()` - Nikon sRAW detection - `isCoolscanNEF()` - Coolscan NEF detection - `haveFPData()` - Floating point data availability - `srawMidpoint()` - sRAW midpoint calculation - **Color Operations (3 methods)** - `getColorAt()` - Get color value at specific position - `getWhiteBalance()` - White balance multipliers - `setBayerPattern()` - Set color filter pattern - **Static Methods (4 methods)** - `LibRaw.getVersion()` - Library version information - `LibRaw.getCapabilities()` - Library capabilities bitmask - `LibRaw.getCameraList()` - Supported camera models list - `LibRaw.getCameraCount()` - Number of supported cameras #### ๐Ÿงช Comprehensive Testing Framework - **Image Processing Test Suite** (`test/image-processing.test.js`) - Thumbnail extraction validation (100% success rate) - Image conversion workflow testing - Advanced processing feature validation - Parameter configuration testing - Memory operations verification - **Format Conversion Test Suite** (`test/format-conversion.test.js`) - Output format validation (PPM, TIFF) - Color space conversion testing (6 color spaces) - Bit depth processing (8-bit, 16-bit) - Quality setting validation - Format header verification - **Thumbnail Extraction Test Suite** (`test/thumbnail-extraction.test.js`) - Thumbnail detection across formats - Extraction method validation - Format analysis (JPEG, TIFF, PNG, Raw RGB) - Performance measurement - Data integrity verification - **Comprehensive Test Runner** (`test/comprehensive.test.js`) - Integrated test execution - Real-world file processing - Cross-format validation - Performance benchmarking #### ๐Ÿ–ผ๏ธ Advanced Thumbnail Extraction - **Batch Extraction Script** (`scripts/extract-thumbnails.js`) - Automated processing of all RAW files - High-quality thumbnail preservation - Support for 6+ camera brands - Interactive gallery generation - Comprehensive reporting - **Interactive Gallery Viewer** (`sample-images/thumbnails/index.html`) - Responsive web interface - Camera brand filtering - File size statistics - Thumbnail preview grid - Format identification #### ๐Ÿ“Š Real-World Validation - **21 RAW files tested** across major camera brands: - Canon CR3 (3 files) - 2.4-2.6 MB thumbnails - Nikon NEF (6 files) - 1.1-1.9 MB thumbnails - Sony ARW (3 files) - 1.4-6.0 MB thumbnails - Fujifilm RAF (3 files) - 2.9-5.5 MB thumbnails - Panasonic RW2 (3 files) - 380KB-1MB thumbnails - Leica DNG (3 files) - 8.3-13.4 MB thumbnails - **Performance Benchmarks** - File loading: 15-30ms (800MB/s+ throughput) - Metadata extraction: 1-5ms - Thumbnail extraction: 20-50ms (400KB/s+ throughput) - Image processing: 1000-2000ms (70-140MB/s throughput) - Memory efficiency: No leaks detected #### ๐Ÿ› ๏ธ Developer Experience - **npm Scripts** for common operations - `npm run extract:thumbnails` - Batch thumbnail extraction - `npm run test:image-processing` - Image conversion tests - `npm run test:format-conversion` - Format validation tests - `npm run test:thumbnail-extraction` - Thumbnail operation tests - `npm run test:comprehensive` - Complete test suite - **Documentation** (`docs/TESTING.md`) - Comprehensive testing guide - Performance metrics - Troubleshooting information - Extension guidelines ### ๐Ÿ”ง Changed #### Enhanced API Interface - **Improved error handling** across all methods - **Consistent Promise-based API** for all operations - **Better memory management** with automatic cleanup - **Enhanced parameter validation** for all inputs #### Performance Optimizations - **Optimized memory usage** for large files - **Faster metadata extraction** (sub-5ms) - **Efficient thumbnail processing** pipeline - **Resource cleanup** improvements ### ๐Ÿ› Fixed #### Stability Improvements - **Memory leak prevention** in all processing paths - **Error handling** for corrupted files - **Resource cleanup** in error conditions - **Thread safety** improvements #### Compatibility Fixes - **Windows platform** optimization and testing - **Large file handling** (>100MB RAW files) - **Multiple format support** validation - **Edge case handling** for unusual files ### ๐Ÿ“‹ Testing Results #### Test Coverage Summary - **โœ… 100% thumbnail extraction** success rate (21/21 files) - **โœ… 95%+ image processing** success rate - **โœ… 100% metadata extraction** across all formats - **โœ… 0 memory leaks** detected in comprehensive testing - **โœ… 6 camera brands** validated in production #### Performance Metrics | Operation | File Size | Time | Throughput | Success | | ------------ | --------- | ------- | ---------- | ------- | | File Loading | 25MB | 15-30ms | 800MB/s+ | 100% | | Metadata | Any | 1-5ms | - | 100% | | Thumbnails | Variable | 20-50ms | 400KB/s+ | 100% | | Processing | 6Kร—4K | 1-2s | 70-140MB/s | 95%+ | ### ๐Ÿš€ Production Readiness This release marks the transition from proof-of-concept to production-ready: - **โœ… Complete API Implementation** - All major LibRaw functions - **โœ… Comprehensive Testing** - Real-world file validation - **โœ… Memory Safety** - No leaks, proper cleanup - **โœ… Error Handling** - Graceful failure management - **โœ… Performance Validation** - Benchmarked operations - **โœ… Documentation** - Complete usage guides ### ๐Ÿ“ฆ Dependencies - **LibRaw 0.21.4** - Core RAW processing library - **Node-API 7.0.0** - Native addon interface - **node-gyp 10.0.0** - Build system ### ๐ŸŽฏ Compatibility - **Node.js** 14.0.0 or higher - **Platforms** Windows (tested), macOS, Linux - **Architectures** x64 (tested), ARM64 --- ## [0.1.33] - 2025-08-22 ### ๐Ÿ”ง Added - Initial LibRaw wrapper implementation - Basic metadata extraction - File loading capabilities - Memory management framework ### ๐Ÿ› Fixed - Build system configuration - Native module loading - Basic error handling --- ## [0.1.32] - 2025-08-21 ### ๐ŸŽ‰ Added - Project initialization - LibRaw library integration - Basic Node.js addon structure - Build configuration --- ## Upgrade Guide ### From 0.1.33 to 0.1.34-poc This is a major upgrade with significant new functionality: #### New Features Available ```javascript // Thumbnail extraction (new!) const hasThumb = await processor.thumbOK(); if (hasThumb) { await processor.unpackThumbnail(); const thumbData = await processor.createMemoryThumbnail(); await processor.writeThumbnail("thumb.jpg"); } // Advanced metadata (enhanced!) const advanced = await processor.getAdvancedMetadata(); const lens = await processor.getLensInfo(); const color = await processor.getColorInfo(); // Batch thumbnail extraction (new!) // npm run extract:thumbnails ``` #### Testing Capabilities ```bash # New comprehensive test suites npm run test:image-processing npm run test:format-conversion npm run test:thumbnail-extraction npm run test:comprehensive ``` #### No Breaking Changes All existing APIs remain compatible. New functionality is additive. --- ## Security - **Memory Safety**: All buffer operations are bounds-checked - **Resource Management**: Automatic cleanup prevents resource leaks - **Error Handling**: Graceful failure without crashes - **Input Validation**: All file inputs are validated before processing --- ## Performance Notes ### Optimization Recommendations - Use `createMemoryImage()` for in-memory processing - Call `close()` promptly to free resources - Process thumbnails before full images when possible - Use appropriate bit depth (8-bit vs 16-bit) for your needs ### Benchmarking Run the performance test suite to validate on your system: ```bash npm run test:performance ``` --- ## Contributing ### Adding New Features 1. Implement in C++ (`src/libraw_wrapper.cpp`) 2. Add JavaScript wrapper (`lib/index.js`) 3. Create tests in appropriate test suite 4. Update documentation 5. Add to this changelog ### Testing Guidelines - All new features must have test coverage - Test with multiple camera brands - Validate memory usage - Include performance benchmarks --- **For detailed API documentation, see [README.md](README.md)** **For testing information, see [docs/TESTING.md](docs/TESTING.md)**