types

package
v0.0.0-...-08f501e Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package types contains common interface definitions and the type registry for reading metadata.

Index

Constants

This section is empty.

Variables

View Source
var PngTemplate []byte

Functions

func NormaliseModelName

func NormaliseModelName(name string) string

func RegisterReader

func RegisterReader(name string, decode func(ImageMetadataContext) (StructuredMetadata, error))

Types

type FileMetadataExtractor

type FileMetadataExtractor struct {
	DateLayouts []string
	LogfileName string
}

FileMetadataExtractor is a common base for file-based metadata extractors.

func (*FileMetadataExtractor) ParseDateFromFilename

func (e *FileMetadataExtractor) ParseDateFromFilename(filename string) (time.Time, error)

type GenerationParameters

type GenerationParameters interface {

	// The version of the software that generated the metadata.
	Version() string

	// The prompt used for the generation.
	PositivePrompt() string
	// The negative prompt used for the generation.
	NegativePrompt() string
	// The model used for the generation.
	Model() string
	// The LoRAs used for the generation.
	LoRAs() []Lora
	// The seed used for the generation.
	Seed() string

	// Raw returns the underlying metadata struct (e.g. fooocus.Metadata).
	// The caller can type-assert it if needed.
	Raw() interface{}
}

GenerationParameters defines a common interface for accessing image generation parameters from different tools.

type ImageMetadataContext

type ImageMetadataContext struct {

	// Original filepath of the image, used to locate any sidecar files
	// if supported. If the image was read from a stream, this may be empty.
	//
	// Note: This is the original path of the image, not the path of any
	// sidecar file. Sidecar files must be located by the extractor if
	// supported.
	Filepath string

	// MIME type of the image, e.g. "image/jpeg", "image/png"
	MIME string

	// All embedded metadata extracted from the image, usually
	// from EXIF blocks or PNG tEXt chunks.
	EmbeddedMetadata map[string]imagemeta.TagInfo
}

type Lora

type Lora struct {
	Name   string
	Weight float32
}

type PngMetadataWriter

type PngMetadataWriter struct {
	Template io.Reader
}

PngMetadataWriter is a common base for metadata writers that embed into PNG.

func NewPngMetadataWriter

func NewPngMetadataWriter() *PngMetadataWriter

func (*PngMetadataWriter) Embed

func (e *PngMetadataWriter) Embed(source io.Reader, target io.Writer, values map[string]interface{}) (err error)

type Reader

type Reader[T any] interface {
	// Decode reads software-specific metadata from the image.
	Decode(ImageMetadataContext) (T, error)
	// Extract reads structured metadata for the image.
	// This could come from embedded metadata or an external source
	// such as a sidecar file.
	Extract(ImageMetadataContext) (StructuredMetadata, error)
}

Reader is an generic interface for extracting metadata.

type StructuredMetadata

type StructuredMetadata struct {
	// Source is the identifier for the tool that generated the metadata,
	// e.g., "Fooocus", "FooocusPlus" or "RuinedFooocus".
	Source string

	Created time.Time
	Params  GenerationParameters
}

type Writer

type Writer[M any] interface {
	Write(target io.Writer, metadata M) error
	CopyWrite(source io.Reader, target io.Writer, metadata M) error
}

Writer is a generic interface for writing metadata.

Jump to

Keyboard shortcuts

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