# DNG to PNG Converter A web application that converts DNG (Digital Negative) files to PNG format with two distinct processing modes: API mode for server-side conversion and WASM mode for client-side conversion. ## ✨ Two Processing Modes ### 🌐 API Mode (Server-side) - High-quality conversion using dcraw + Sharp libraries - Supports large DNG files (up to 50MB) - Full RAW processing pipeline - Reliable server-side processing ### ⚡ WASM Mode (Client-side) - Fast browser-based processing using WebAssembly - Complete privacy - files never leave your device - Works offline after initial page load - Instant processing with dcraw.js ## Tech Stack - **Backend**: Node.js + Express + TypeScript - **API Mode**: dcraw (Node.js) + Sharp - **WASM Mode**: dcraw.js (WebAssembly) - **File Upload**: Multer (API mode only) - **Frontend**: HTML5 + Vanilla JavaScript ## Installation and Setup ### 1. Install Dependencies ```bash npm install ``` ### 2. Run Development Server (Both Modes) ```bash npm run dev ``` Access at `http://localhost:3000` and choose your preferred mode. ### 3. Run API Mode Only ```bash npm run dev:api ``` Access API mode directly at `http://localhost:3001` ### 4. Production Build ```bash npm run build npm start ``` ## Usage ### Mode Selection 1. Open `http://localhost:3000` in your browser 2. Choose between **API Mode** or **WASM Mode** 3. Upload your DNG file 4. Download the converted PNG file ### API Mode Usage - Best for: Large files, highest quality conversion - Upload DNG file → Server processes → Download PNG ### WASM Mode Usage - Best for: Privacy, speed, offline use - Select DNG file → Browser processes → Download PNG ## API Endpoints ### POST /convert Converts DNG files to PNG format. **Request:** - Method: POST - Content-Type: multipart/form-data - Body: DNG file (dngFile field) **Response:** ```json { "message": "Conversion completed successfully.", "filename": "converted-file.png" } ``` ### GET /download/:filename Downloads the converted PNG file. ## Testing ### Conversion Function Test ```bash npm run test-conversion ``` ### dcraw Library Test ```bash npx ts-node test/test-dcraw.ts ``` ### Create Test Image ```bash npx ts-node test/create-test-image.ts ``` ## Supported File Formats - **Input**: .dng (Digital Negative) files - **Output**: .png (Portable Network Graphics) files ## Limitations - Maximum file size: 50MB - Only DNG format supported (other RAW formats not supported) ## Project Structure ``` dng/ ├── src/ │ ├── index.ts # Main server with mode selection │ ├── api-mode/ │ │ ├── index.ts # Standalone API server │ │ ├── server.ts # API mode router │ │ └── dng-converter.ts # Server-side conversion logic │ └── wasm-mode/ # (Client-side processing via static files) ├── public/ │ └── wasm-mode.html # WASM mode interface ├── test/ │ ├── test-conversion.ts # Conversion test script │ ├── test-dcraw.ts # dcraw library test │ └── create-test-image.ts # Test image creation ├── uploads/ # Temporary storage for uploaded files ├── test-files/ # Test file storage ├── dist/ # Compiled JavaScript files ├── package.json ├── tsconfig.json └── README.md ``` ## Available Scripts - `npm run dev` - Run main server with mode selection (port 3000) - `npm run dev:api` - Run API mode only (port 3001) - `npm run test-conversion` - Test conversion functionality - `npm run test-dcraw` - Test dcraw library - `npm run create-test-image` - Create test images - `npm run build` - Build for production - `npm start` - Start production server ## Troubleshooting ### DNG File Conversion Failure 1. Verify the file is in proper DNG format 2. Check if file size is under 50MB 3. Ensure the file is not corrupted ### Server Start Failure 1. Check Node.js version (14.x or higher recommended) 2. Verify port 3000 is not in use 3. Ensure all dependencies are installed ## License ISC ## Developer Notes This project uses the dcraw WASM library for DNG file processing. DNG is an open RAW format developed by Adobe that standardizes RAW files generated by various cameras.