Native Node.js addon (N-API) to convert camera RAW files (CR2/CR3/NEF/ARW/RW2, etc.) to 16-bit TIFF using LibRaw. Works on Linux, macOS, and Windows. Ships prebuild support; falls back to local build if needed.
Use your preferred package manager:
# npm npm install c-libraw
# pnpm pnpm add c-libraw
# yarn yarn add c-libraw- On install, prebuilt binaries are downloaded when available.
- If no prebuild matches your platform, it will compile from source.
const { convertCR2ToTIFF } = require('c-libraw');
// Converts any LibRaw-supported RAW (CR2/CR3/NEF/ARW/RW2, etc.) to a 16-bit TIFF
// Synchronous API: returns true on success, throws on failure
convertCR2ToTIFF('/path/input.CR2', '/path/output.tiff');Notes:
- The API is synchronous. For heavy workloads, consider
worker_threadsor a job queue. - Despite the name,
convertCR2ToTIFFaccepts any RAW format supported by LibRaw.
- Node.js >= 18
- When using prebuilds: no native toolchain required.
- When building from source (automatic fallback):
- Linux
- Build tools: Python 3, C++17 compiler (g++/clang), make
- LibRaw development package
- Debian/Ubuntu:
sudo apt-get install libraw-dev - Fedora/RHEL:
sudo dnf install LibRaw-devel - Arch:
sudo pacman -S libraw
- Debian/Ubuntu:
- macOS
- Xcode Command Line Tools (
xcode-select --install) - LibRaw:
brew install libraw
- Xcode Command Line Tools (
- Windows
- Visual Studio Build Tools (Desktop C++ workload) + Python 3
- LibRaw via vcpkg:
vcpkg install libraw:x64-windows - Environment variables recognized by the build:
VCPKG_ROOT(defaults toC:/vcpkgif not set)VCPKG_TRIPLET(defaults tox64-windows)
- Linux
- Uses
prebuild-installat install time to fetch prebuilt binaries. - Uses
node-gyp-buildat runtime to load a prebuild or a locally built.nodebinary.
- Linker error on Linux/macOS (e.g.,
cannot find -lraw): install the LibRaw dev package (see above). - Build errors on Windows: ensure VS Build Tools and vcpkg are installed; check
VCPKG_ROOTandVCPKG_TRIPLET. - ABI/runtime mismatch: force a rebuild from source
npm install c-libraw --build-from-source # or pnpm rebuild c-libraw --config.node_gyp_rebuild=true
To produce and bundle prebuilds (recommended before publishing):
pnpm run prebuild # generates N-API prebuilds under libraw/prebuilds/These will be picked up automatically by node-gyp-build when users install the package.
ISC