DotNetRAW 1.0.0

dotnet add package DotNetRAW --version 1.0.0
                    
NuGet\Install-Package DotNetRAW -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DotNetRAW" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DotNetRAW" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DotNetRAW" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DotNetRAW --version 1.0.0
                    
#r "nuget: DotNetRAW, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DotNetRAW@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DotNetRAW&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DotNetRAW&version=1.0.0
                    
Install as a Cake Tool

DotNetRAW

Build Status NuGet Issues Status License
Contact Sponsor

About

Camera RAW metadata library for C# / .NET.

This library provides a simple, read-only interface to open camera RAW files and read their image geometry, colour calibration, lens identity and shooting metadata, along with the raw 16-bit Bayer sensor buffer. It is a managed binding over the native LibRAW library, reached through P/Invoke.

Status

DotNetRAW is deliberately read-only. It opens a RAW file, unpacks the sensor data, and surfaces the metadata as immutable values and the raw Bayer buffer as a caller-owned copy. It does not demosaic or render the image, decode embedded thumbnails or previews, apply white balance, or write any format — it reads what the camera recorded and hands it back.

Scope & Limitations

These are intentional properties of the library, not latent surprises:

  • Read-only: there is no demosaicing, thumbnail/preview extraction, colour rendering or writing. The library exposes LibRAW's parsed metadata and the raw, unprocessed 16-bit Bayer samples.
  • Native dependency: unlike a pure-managed library, DotNetRAW needs the native LibRAW binary at run time. The matching binary is bundled and loaded automatically (see Requirements).
  • Deterministic disposal: a RAWFile owns a native LibRAW context, so it is IDisposable. Dispose it — ideally with a using statement — to release the native resources promptly; a finalizer is only a safety net. Every data accessor throws ObjectDisposedException after disposal.
  • The raw buffer is unprocessed: RawImage is the 16-bit Bayer mosaic exactly as LibRAW unpacks it (or null when the sensor exposes no Bayer buffer — for example a non-Bayer layout — or before the sensor data has been unpacked). Turning it into a viewable image is the caller's responsibility.
  • Culture-invariant: every value description renders identically regardless of the machine's current culture.
  • Not thread-safe: a RAWFile wraps a mutable native context, so an instance must not be used from multiple threads without external synchronization.

Requirements

DotNetRAW targets .NET 10. Its one dependency is the native LibRAW library, version 0.22.2, which is bundled with the library for each supported platform — no separate install or build is required:

  • Windowswin-x64
  • macOS — Apple Silicon and Intel (a single universal binary)

The correct native binary is copied next to your application automatically and resolved at run time by import name. The library is continuously built and tested on Windows (see the CI badge above) in both Debug and Release configurations, and developed and tested on macOS.

Installation

DotNetRAW is available on NuGet. Add it to your project with the .NET CLI:

dotnet add package DotNetRAW

Or add a <PackageReference> to your project file:

<PackageReference Include="DotNetRAW" Version="1.0.0" />

Building

The solution (DotNetRAW.slnx) contains the DotNetRAW class library and the DotNetRAWTests xUnit test suite:

dotnet build DotNetRAW.slnx -c Release
dotnet test  DotNetRAW.slnx -c Release

Example Usage

Reading metadata
using System;
using DotNetRAW;

try
{
    // Open a RAW file. By default the sensor data is unpacked eagerly, so any open or
    // unpack failure surfaces right here.
    using RAWFile file = new RAWFile( "/path/to/photo.cr3" );

    // A rich, one-line summary: camera, sensor dimensions, CFA, exposure and lens.
    Console.WriteLine( file );

    // Each metadata group is its own immutable record with a readable description.
    Console.WriteLine( file.ImageInfo );   // camera make, model and colour count
    Console.WriteLine( file.ImageSizes );  // raw and output geometry
    Console.WriteLine( file.CfaPattern );  // colour-filter-array layout
    Console.WriteLine( file.ShotInfo );    // ISO, shutter, aperture, focal length
    Console.WriteLine( file.LensInfo );    // lens identity and focal range

    // Some metadata is optional and may be absent.
    if( file.GpsInfo is RAWGPSInfo gps )
    {
        Console.WriteLine( gps );
    }
}
catch( RAWException exception )
{
    Console.WriteLine( exception.Message );
}
Accessing the raw sensor buffer
using System;
using DotNetRAW;

using RAWFile file = new RAWFile( "/path/to/photo.cr3" );

// The unpacked 16-bit Bayer samples, copied into a managed array (null when the sensor
// exposes no Bayer buffer).
if( file.RawImage is ushort[] samples )
{
    Console.WriteLine( samples.Length + " raw samples" );
}

// Or read the samples in place, without copying, through a borrowed span.
ushort brightest = file.WithRawImage( span =>
{
    ushort max = 0;

    foreach( ushort sample in span )
    {
        if( sample > max )
        {
            max = sample;
        }
    }

    return max;
} );

Console.WriteLine( brightest );

Opening is eager by default; pass new RAWParsingOptions( unpacksImmediately: false ) to defer unpacking and call RAWFile.Unpack() yourself later. A file can also be opened from an in-memory byte[] instead of a path.

License

DotNetRAW is released under the terms of the MIT License.

The bundled native LibRAW library is distributed under its own terms (LGPL-2.1 or CDDL-1.0), which apply to that binary only.

Repository Infos

Owner:          Jean-David Gadina - XS-Labs
Web:            www.xs-labs.com
Blog:           www.noxeos.com
Twitter:        @macmade
GitHub:         github.com/macmade
LinkedIn:       ch.linkedin.com/in/macmade/
StackOverflow:  stackoverflow.com/users/182676/macmade
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 116 7/19/2026