metadata

package module
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: 8 Imported by: 0

README

fooocus-metadata

A Go library for reading and writing image generation parameters for images produced by Fooocus and various forks.

Features

  • Read embedded metadata (PNG, EXIF) for image files generated by Fooocus.
  • Read metadata from the Private Log file as fallback if metadata was not embedded into the original file.
  • Write metadata to PNG, which can be loaded into Fooocus through Input Image > Metadata.

Usage

This library is intended to be used programmatically. It includes a command line tool to read metadata from a file, which serves as a usage example.

Compatibility

Fooocus

Tested with Fooocus version 2.1 and newer.

Fooocus supports two metadata schemes:

  • fooocus (json) - the native scheme.
  • a1111 (plain text) - for compatibility with Civitai.

This library fully supports the native fooocus scheme.

Partial support for reading the a1111 scheme is provided by the generic A1111-style metadata parser, but it does not support any Fooocus-specific keys.

Image Format Metadata Location Metadata Scheme Read Write
PNG Embedded fooocus
JPG, WEBP Embedded fooocus
* Embedded a1111 ⚠️
PNG, JPG, WEBP External (Private Log) fooocus
FooocusPlus

Tested with FooocusPlus version 1.0.0 and newer.

Image Format Metadata Location Metadata Scheme Read Write
PNG Embedded JSON
JPG, WEBP Embedded JSON
PNG, JPG, WEBP External (Private Log) JSON
RuinedFooocus

Tested with RuinedFooocus version 2.0.0 and newer.

Image Format Metadata Location Metadata Scheme Read Write
PNG Embedded JSON
AUTOMATIC1111-style metadata

Basic read-only support for metadata encoded in a1111 (plain text) format. Unsupported keys are ignored.

Tested with:

Image Format Metadata Location Metadata Scheme Read Write
PNG, JPEG, WEBP Embedded a1111

Documentation

Overview

Package metadata provides high-level functions to extract image generation parameters from image files.

This supports multiple sources, including Fooocus, FooocusPlus and RuinedFooocus.

Example usage:

To read metadata, first register the sources you want to enable by importing the appropriate package:

import (
  _ "github.com/fkleon/fooocus-metadata/fooocus"
)

To read metadata from a file, use ExtractFromFile:

path := "fooocus/testdata/fooocus-meta.png"
meta, err := ExtractFromFile(path)
fmt.Println(meta.Version) // prints "Fooocus v2.5.5"

To read metadata from a stream, use ExtractFromReader. You can provide a hint about the original filepath to enable path-based features such as sidecar support:

path := "fooocus/testdata/fooocus-meta.png"
file, err := os.Open(path)
defer file.Close()
meta, err := ExtractFromReader(file, WithPath(path))
fmt.Println(meta.Version) // prints "Fooocus v2.5.5"

To write metadata, use the individual metadata writers provided by each package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFromFile

func ExtractFromFile(path string) (params types.StructuredMetadata, err error)

func ExtractFromReader

func ExtractFromReader(reader io.ReadSeeker, opts ...Option) (params types.StructuredMetadata, err error)

Types

type Config

type Config struct {
	Path string
}

type ExtractOptions

type ExtractOptions struct {
	// The path of the file to read image metadata from.
	File string
}

ExtractOptions contains the options for the Extract function.

type Option

type Option func(*Config)

func WithPath

func WithPath(path string) Option

To enable path-based extraction features, e.g. parsing creation date from file pattern or sidecar support

Directories

Path Synopsis
cmd
embed command
A command-line tool to embed image generation parameters into an image file.
A command-line tool to embed image generation parameters into an image file.
extract command
A command-line tool to extract image generation parameters from an image file or sidecar file.
A command-line tool to extract image generation parameters from an image file or sidecar file.
Package fooocus implements reading and writing Fooocus metadata (image generation parameters).
Package fooocus implements reading and writing Fooocus metadata (image generation parameters).
Package fooocusplus implements reading and writing [FooocusPlus] metadata (image generation parameters).
Package fooocusplus implements reading and writing [FooocusPlus] metadata (image generation parameters).
internal
image
Package image provides utilities to detect image MIME types and read embedded image metadata (EXIF or PNG tEXt).
Package image provides utilities to detect image MIME types and read embedded image metadata (EXIF or PNG tEXt).
Package ruinedfooocus implements reading and writing [RuinedFooocus] metadata (image generation parameters).
Package ruinedfooocus implements reading and writing [RuinedFooocus] metadata (image generation parameters).
Package stablediffusion implements reading [AUTOMATIC1111] style plaintext metadata (image generation parameters).
Package stablediffusion implements reading [AUTOMATIC1111] style plaintext metadata (image generation parameters).
Package types contains common interface definitions and the type registry for reading metadata.
Package types contains common interface definitions and the type registry for reading metadata.

Jump to

Keyboard shortcuts

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