Skip to content
/ rawkit Public

Rawkit is a (C++/Go) Image manipulation library. Rawkit lets Go programs open RAW and manipulate RAW images and some utilities for working with images..

Notifications You must be signed in to change notification settings

tlaceby/rawkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RawKit

Rawkit is a CGO wrapper around LibRaw that lets Go programs open and manipulate RAW image files without needing a C compiler or external dependencies.

Quick Start

Install rawkit using Go tooling:

go get github.com/tlaceby/rawkit@latest

Load and Inspect RAW Metadata

package main

import (
	"fmt"
	"github.com/tlaceby/rawkit"
)

func main() {
	img, err := rawkit.LoadRAW("example.ARW")
	if err != nil {
		panic(err)
	}

	fmt.Printf("Image: %dx%d | Channels: %d | Buffer Size: %d\n", 
		img.Width, img.Height, img.Colors, len(img.Buffer))
	fmt.Println("Camera:", img.CameraMake, img.CameraModel)
	fmt.Println("Lens:", img.FocalLength, "mm  f/", img.Aperature)
	fmt.Println("Exposure:", img.ShutterSpeed, "sec  ISO", img.ISO)
	fmt.Println("Artist:", img.Artist)
}

View the API Documentation to see all avbailable types and methods which Rawkit provides.

Custom Image Operations

Rawkit aims to be full of useful features which make working with RAW and Non-RAW Images easier. Below are some of the additional functions/methods you can use to work with Images in Rawkit.

Generating Histograms
// Get luminance histogram data from RAW image
img, _ := rawkit.GetUnderlyingImageFromFile("my-image.ARW", true) // with with most common and (RAW) image types
h := histograms.HistogramFromImage(img)

// Create image 
if err = h.CreateRGBHistogramImage("histogram-RGB.png", histograms.DefaultHistogramOptions()); err != nil {
	panic(err)
}

// Using custom properties
opts := rawkit.DefaultHistogramOptions()
opts.LuminanceLineColor = color.RGBA{0, 255, 255, 255} // cyan
opts.GenerateLuminanceImage = true
opts.height = 1920
opts.Width = 1080
opts.ShowGrid = false

if err = h.CreateRGBHistogramImage("histogram-LuminancePeaks.png", opts); err != nil {
	panic(err)
}

Available Metadata

  • Camera: CameraMake, CameraModel
  • Exposure: ShutterSpeed, Aperature, FocalLength, ISO
  • Image: Width, Height, Colors, Flip
  • Other: Artist, DNGVersion, RawCount, AsShotWBApplied

Pixel data is accessible in img.Buffer as []uint16 representing unpacked pixels in channel-major order.

Contributing

  • Bug reports - open an issue with steps to reproduce
  • Pull requests - fork, branch, commit, ensure go test ./... passes
  • Code style - use idiomatic Go and minimal C++

Extending RawKit

To add new functionality:

  1. Bridge (wrapper/) - Add extern "C" function to wrapper.cpp/.h
  2. Expose (rawkit/) - Declare function in CGO preamble and wrap in Go
  3. Test (tests/) - Add Go test with test files in tests/testdata/
  4. Verify - Run make release to build, test, and bump version

Building

Development

make verify

Release

make release

This builds LibRaw and the wrapper, runs tests, and bumps the version if tests pass.

About

Rawkit is a (C++/Go) Image manipulation library. Rawkit lets Go programs open RAW and manipulate RAW images and some utilities for working with images..

Topics

Resources

Stars

Watchers

Forks