Skip to content

hmmhmmhm/dng-to-png

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

npm install

2. Run Development Server (Both Modes)

npm run dev

Access at http://localhost:3000 and choose your preferred mode.

3. Run API Mode Only

npm run dev:api

Access API mode directly at http://localhost:3001

4. Production Build

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:

{
  "message": "Conversion completed successfully.",
  "filename": "converted-file.png"
}

GET /download/:filename

Downloads the converted PNG file.

Testing

Conversion Function Test

npm run test-conversion

dcraw Library Test

npx ts-node test/test-dcraw.ts

Create Test Image

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.

About

Node.js solution for converting DNG files to PNG

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •