golibraw

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2023 License: GPL-3.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

golibraw

Simple Go wrapper for libraw

Forked from enricod/golibraw.

Prerequisites

brew install libraw                       # on OSX
sudo apt-get install libraw-dev           # on Ubuntu

go install github.com/inokone/golibraw@latest

Usage example

import (
    "bytes"
    "fmt"
    "image/jpeg"
    raw "github.com/inokone/golibraw"
)

func main() {
    path := "/Downloads/example.cr2"

    // Get metadata from the RAW image on Camera, Lens and Settings - fast operation
    metadata, err := raw.ExtractMetadata(path)
    if err != nil {
        fmt.Println("Metadata export error: ", err)
    }
    fmt.Println("Metadata: ", metadata)

    // Get the embedded thumbnail from RAW if exists - fast operation
    err = raw.ExtractThumbnail(path, "/Downloads/out.jpeg")
    if err != nil {
        fmt.Println("Error while extracting embedded thumbnail, maybe it is not present: ", err)
    }

    // Import the RAW file as an image.Image - slow operation
    image, err := raw.ImportRaw(path)
    if err != nil {
        fmt.Println("RAW import error: ", err)
    }

    // Export the image as JPEG 
    buf := new(bytes.Buffer)
    err = jpeg.Encode(buf, image, nil)
    if err != nil {
        fmt.Println("Error while exporting image: ", err)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportPPM

func ExportPPM(inputPath string, exportPath string) error

Reads a RAW image file from file system and exports it to PPM format

func ExtractThumbnail

func ExtractThumbnail(inputPath string, exportPath string) error

Reads a RAW image file from file system and exports the embedded thumbnail image - if it exists - to the path defined by exportPath parameter. This method is significantly faster than importing the RAW image file.

func ImportRaw

func ImportRaw(path string) (image.Image, error)

Reads a RAW image file from file system and converts it to standard image.Image

Types

type Camera

type Camera struct {
	Make     string
	Model    string
	Software string
	Colors   uint
}

type Lens

type Lens struct {
	Make           string
	Model          string
	Serial         string
	MinFocal       float64
	MaxFocal       float64
	MaxAp4MinFocal float64
	MaxAp4MaxFocal float64
}

type Metadata

type Metadata struct {
	Timestamp int64
	Width     int
	Height    int
	DataSize  int64
	Camera    Camera
	Lens      Lens
	ISO       int
	Aperture  float64
	Shutter   float64
}

func ExtractMetadata

func ExtractMetadata(path string) (Metadata, error)

Reads a RAW image file from file system and exports collected metadata. This method is significantly faster than importing the RAW image file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址