Skip to content

strawberryworks/go-libraw

Repository files navigation

go-libraw

go-libraw project cover

CI codecov Go Reference

go-libraw provides Go bindings to LibRaw for reading and processing of RAW digicam images.

Requirements

go-libraw targets Linux and macOS (amd64, arm64). Windows is out of scope; see the Support Matrix for details.

  • Go 1.26 or newer, as declared by go.mod
  • cgo enabled
  • LibRaw 0.21 or newer (libraw-dev or equivalent)
  • a C/C++ toolchain for the target platform

Install LibRaw on common platforms:

# macOS
brew install libraw

# Debian/Ubuntu
sudo apt-get update
sudo apt-get install -y libraw-dev pkg-config

# Fedora
sudo dnf install LibRaw-devel pkgconf-pkg-config

Verify local discovery:

make libraw-check

See LibRaw Build Setup and the Support Matrix for platform details.

Quick Start

go get github.com/strawberryworks/go-libraw/pkg/libraw
package main

import (
	"log"

	libraw "github.com/strawberryworks/go-libraw/pkg/libraw"
)

func main() {
	processor, err := libraw.NewProcessor()
	if err != nil {
		log.Fatal(err)
	}
	defer func() {
		if err := processor.Close(); err != nil {
			log.Fatal(err)
		}
	}()

	if err := processor.OpenFile("input.cr2"); err != nil {
		log.Fatal(err)
	}
	if err := processor.Unpack(); err != nil {
		log.Fatal(err)
	}
	if err := processor.DcrawProcess(); err != nil {
		log.Fatal(err)
	}
	if err := processor.WritePPMTiff("output.ppm"); err != nil {
		log.Fatal(err)
	}
}

Run the bundled example on checked-in fixtures:

make examples
make clean

The sample commands are mapped to upstream LibRaw samples in LibRaw Sample Parity Examples.

API Concepts

  • Processor owns one LibRaw handle. Create it with NewProcessor, then call Close when finished.
  • Opening input with OpenFile, OpenBuffer, or OpenBayer prepares metadata and decoder state.
  • Processing follows LibRaw order: open, optionally set params, Unpack, DcrawProcess or lower-level image operations, then write or copy output.
  • Metadata returns a Go snapshot of LibRaw metadata and maker-note summaries.
  • Raw image, thumbnail, and memory image helpers return Go-owned data.
  • LibRaw error codes are returned as Go errors; use ErrorCode and StrError when you need to inspect an underlying LibRaw status.

Documentation

Upstream Coverage

The generated inventory in docs/libraw-api-inventory.md tracks LibRaw symbols from the fixture headers and marks each as wrapped, internal, deferred, unsupported, or unmapped. Run this before changing coverage-related code:

make check-api-inventory

To regenerate the inventory after updating the coverage map:

make api-inventory

License

The Go binding code in this repository is licensed under the MIT License; see LICENSE. That license covers only this project's own code.

go-libraw links the third-party LibRaw library (dual-licensed CDDL-1.0 OR LGPL-2.1-or-later) and checks in copies of LibRaw's public headers under testdata/headers/libraw/, which remain under LibRaw's license rather than MIT. Software you build and distribute from this binding links LibRaw and must satisfy LibRaw's license. See THIRD-PARTY-NOTICES.md for the full attribution and distribution notes (including static-linking guidance), and licenses/ for the complete LibRaw license texts.

About

Povides Go bindings to LibRaw for reading and processing of RAW digicam images

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors