indexer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package indexer implements the core photo indexing engine with concurrent processing.

It extracts EXIF metadata, generates aspect-ratio-preserving thumbnails, analyzes color palettes, computes perceptual hashes, and infers additional metadata like time of day and season. The engine uses a worker pool pattern for parallel file processing and guarantees read-only access to photo files.

Index

Constants

View Source
const LibRawImpl = "inokone/golibraw"

LibRawImpl identifies which library implementation is in use

Variables

This section is empty.

Functions

func AreSimilar

func AreSimilar(hash1, hash2 string, threshold int) (bool, error)

AreSimilar checks if two images are similar based on their perceptual hashes threshold defines the maximum Hamming distance for similarity Common thresholds:

0-5: Identical/near-identical
6-10: Very similar
11-15: Similar (burst variations)
16-20: Somewhat similar
21+: Different

func ColourDistance

func ColourDistance(c1, c2 models.Colour) float64

ColourDistance calculates the Euclidean distance between two colours in RGB space

func ComputePerceptualHash

func ComputePerceptualHash(img image.Image) (string, error)

ComputePerceptualHash computes a perceptual hash (pHash) for an image

func DecodeRaw

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

DecodeRaw attempts to decode a RAW image file using LibRaw (inokone/golibraw) Returns image.Image on success, error on failure

func ExportPerfStatsJSON

func ExportPerfStatsJSON(filename string, summary models.PerfSummary, detailed []models.PerfStats) error

ExportPerfStatsJSON exports detailed performance statistics to a JSON file

func ExtractColourPalette

func ExtractColourPalette(img image.Image, numColours int) ([]models.DominantColour, error)

ExtractColourPalette extracts the dominant colours from an image

func ExtractEmbeddedJPEG

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

ExtractEmbeddedJPEG extracts the embedded JPEG preview from a DNG file DNG files (which are TIFF-based) often contain embedded JPEG previews This function finds the LARGEST valid embedded JPEG (best quality)

func ExtractMetadata

func ExtractMetadata(filePath string) (*models.PhotoMetadata, error)

ExtractMetadata extracts EXIF metadata using the exif-go library

func FromStandardColour

func FromStandardColour(c color.Color) models.Colour

FromStandardColour converts color.Color to models.Colour

func GenerateThumbnails

func GenerateThumbnails(filePath string) (map[models.ThumbnailSize][]byte, error)

GenerateThumbnails generates multiple thumbnail sizes from an image file Each thumbnail preserves aspect ratio with longest edge constrained to the specified size

func GenerateThumbnailsFromImage

func GenerateThumbnailsFromImage(img image.Image) (map[models.ThumbnailSize][]byte, error)

GenerateThumbnailsFromImage generates thumbnails from an already-decoded image

func HSLToRGB

func HSLToRGB(hsl models.ColourHSL) models.Colour

HSLToRGB converts an HSL colour to RGB colour space

func HammingDistance

func HammingDistance(hash1, hash2 string) (int, error)

HammingDistance calculates the Hamming distance between two perceptual hashes

func InferMetadata

func InferMetadata(metadata *models.PhotoMetadata)

InferMetadata adds inferred metadata based on extracted EXIF data

func IsRawSupported

func IsRawSupported() bool

IsRawSupported returns true if LibRaw support is compiled in

func PrintPerfStats

func PrintPerfStats(summary models.PerfSummary, detailed []models.PerfStats)

PrintPerfStats outputs performance statistics in a human-friendly, machine-readable format

func ToStandardColour

func ToStandardColour(c models.Colour) color.Color

ToStandardColour converts models.Colour to color.Color interface

Types

type BurstDetector

type BurstDetector struct {
	// contains filtered or unexported fields
}

BurstDetector detects burst photo sequences

func NewBurstDetector

func NewBurstDetector(db *database.DB) *BurstDetector

NewBurstDetector creates a new burst detector with default settings

func (*BurstDetector) DetectBursts

func (bd *BurstDetector) DetectBursts() ([][]int, error)

DetectBursts finds all burst sequences in the database

func (*BurstDetector) GetAllBursts

func (bd *BurstDetector) GetAllBursts() ([]BurstGroup, error)

GetAllBursts retrieves all burst groups from the database

func (*BurstDetector) GetBurstStats

func (bd *BurstDetector) GetBurstStats() (int, int, error)

GetBurstStats returns statistics about detected bursts

func (*BurstDetector) SaveBursts

func (bd *BurstDetector) SaveBursts(bursts [][]int) error

SaveBursts saves detected burst groups to the database

type BurstGroup

type BurstGroup struct {
	ID        string
	PhotoIDs  []int
	CreatedAt time.Time
}

BurstGroup represents a detected burst group

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the main indexer engine

func NewEngine

func NewEngine(db *database.DB, workerCount int) *Engine

NewEngine creates a new indexer engine

func (*Engine) Close

func (e *Engine) Close() error

Close closes the engine and any associated resources

func (*Engine) EnablePerfTracking

func (e *Engine) EnablePerfTracking()

EnablePerfTracking enables detailed performance tracking

func (*Engine) GetPerfStats

func (e *Engine) GetPerfStats() []models.PerfStats

GetPerfStats returns the collected performance statistics

func (*Engine) GetPerfSummary

func (e *Engine) GetPerfSummary() models.PerfSummary

GetPerfSummary returns the aggregate performance summary

func (*Engine) GetStats

func (e *Engine) GetStats() models.IndexStats

GetStats returns the current indexing statistics

func (*Engine) IndexDirectory

func (e *Engine) IndexDirectory(rootPath string) error

IndexDirectory recursively indexes all DNG files in a directory

func (*Engine) SetProgressCallback

func (e *Engine) SetProgressCallback(callback ProgressCallback)

SetProgressCallback sets the progress callback function

type Photo

type Photo struct {
	ID          int
	FilePath    string
	DateTaken   time.Time
	CameraMake  string
	CameraModel string
	FocalLength float64
}

Photo represents a photo for burst detection

type ProgressCallback

type ProgressCallback func(processed, total int)

ProgressCallback is called with progress updates

Jump to

Keyboard shortcuts

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