Skip to content

Wayoyo-Digital/c-libraw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c-libraw

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.

Install

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.

Quick start

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_threads or a job queue.
  • Despite the name, convertCR2ToTIFF accepts any RAW format supported by LibRaw.

Runtime and build requirements

  • 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
    • macOS
      • Xcode Command Line Tools (xcode-select --install)
      • LibRaw: brew install libraw
    • 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 to C:/vcpkg if not set)
        • VCPKG_TRIPLET (defaults to x64-windows)

How it loads

  • Uses prebuild-install at install time to fetch prebuilt binaries.
  • Uses node-gyp-build at runtime to load a prebuild or a locally built .node binary.

Troubleshooting

  • 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_ROOT and VCPKG_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

Maintainers (prebuilds)

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.

License

ISC

About

Use Libraw on Nodejs Backend

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors