image

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractTimestampFromPath

func ExtractTimestampFromPath(path string) (time.Time, error)

ExtractTimestampFromPath extracts the timestamp from a timestamped path Returns zero time if the path doesn't have a valid timestamp

func GenerateTimestampedPath

func GenerateTimestampedPath(originalPath string) string

GenerateTimestampedPath generates a timestamped relative path for an image Format: YYYYMMDD_HHMMSS_microseconds_originalfilename.ext Example: 20251015_143052_123456_yorkshire-terrier.jpg

func GenerateTimestampedPathWithPrefix

func GenerateTimestampedPathWithPrefix(originalPath, prefix string) string

GenerateTimestampedPathWithPrefix generates a timestamped path with custom prefix

func GetOriginalFilename

func GetOriginalFilename(timestampedPath string) string

GetOriginalFilename extracts the original filename from a timestamped path

func IsTimestampedPath

func IsTimestampedPath(path string) bool

IsTimestampedPath checks if a path follows the timestamped format

Types

type EXIFData

type EXIFData struct {
	Make         string  `json:"make,omitempty"`
	Model        string  `json:"model,omitempty"`
	DateTime     string  `json:"datetime,omitempty"`
	Orientation  int     `json:"orientation,omitempty"`
	Width        int     `json:"width,omitempty"`
	Height       int     `json:"height,omitempty"`
	FNumber      float64 `json:"f_number,omitempty"`
	ExposureTime string  `json:"exposure_time,omitempty"`
	ISO          int     `json:"iso,omitempty"`
	FocalLength  string  `json:"focal_length,omitempty"`
	GPSLatitude  float64 `json:"gps_latitude,omitempty"`
	GPSLongitude float64 `json:"gps_longitude,omitempty"`
	GPSAltitude  float64 `json:"gps_altitude,omitempty"`
}

EXIFData represents extracted EXIF metadata

func ExtractEXIF

func ExtractEXIF(filePath string) (*EXIFData, error)

ExtractEXIF extracts EXIF metadata from an image file

func ExtractEXIFFromBytes

func ExtractEXIFFromBytes(imageData []byte) (*EXIFData, error)

ExtractEXIFFromBytes extracts EXIF metadata from image bytes

func (*EXIFData) IsEmpty

func (e *EXIFData) IsEmpty() bool

IsEmpty returns true if no EXIF data was extracted

func (*EXIFData) ToJSON

func (e *EXIFData) ToJSON() (string, error)

ToJSON converts EXIFData to JSON string

type NoOpOCRExtractor

type NoOpOCRExtractor struct{}

NoOpOCRExtractor provides a no-op implementation when Tesseract is not available

func (*NoOpOCRExtractor) ExtractFromBytes

func (n *NoOpOCRExtractor) ExtractFromBytes(imageData []byte) (*OCRData, error)

ExtractFromBytes returns an error indicating OCR is not available

func (*NoOpOCRExtractor) ExtractFromFile

func (n *NoOpOCRExtractor) ExtractFromFile(filePath string) (*OCRData, error)

ExtractFromFile returns an error indicating OCR is not available

func (*NoOpOCRExtractor) ExtractWithLanguage

func (n *NoOpOCRExtractor) ExtractWithLanguage(filePath string, language string) (*OCRData, error)

ExtractWithLanguage returns an error indicating OCR is not available

type OCRData

type OCRData struct {
	Text       string  `json:"text"`
	Confidence float64 `json:"confidence"`
	Language   string  `json:"language"`
	HasText    bool    `json:"has_text"`
}

OCRData represents extracted OCR text and confidence

func (*OCRData) GetTextSummary

func (o *OCRData) GetTextSummary(maxLength int) string

GetTextSummary returns a short summary of the OCR text

func (*OCRData) IsEmpty

func (o *OCRData) IsEmpty() bool

IsEmpty returns true if no text was extracted

func (*OCRData) WordCount

func (o *OCRData) WordCount() int

WordCount returns the number of words in the extracted text

type OCRExtractor

type OCRExtractor interface {
	ExtractFromBytes(imageData []byte) (*OCRData, error)
	ExtractFromFile(filePath string) (*OCRData, error)
	ExtractWithLanguage(filePath string, language string) (*OCRData, error)
}

OCRExtractor interface for OCR functionality

func GetOCRExtractor

func GetOCRExtractor() OCRExtractor

GetOCRExtractor returns an OCR extractor instance This will return a NoOpOCRExtractor if Tesseract is not available

func NewTesseractExtractor

func NewTesseractExtractor() (OCRExtractor, error)

NewTesseractExtractor creates a new Tesseract OCR extractor Returns an error if Tesseract is not available

Jump to

Keyboard shortcuts

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