...

Package iccextract

Overview ▾

Package iccextract extracts embedded ICC colour profiles from encoded image containers (JPEG, PNG, TIFF). It performs no colour management; it only locates and returns the raw profile bytes together with the detected container format, so that callers can preserve the profile when embedding the image into a PDF.

The extractors are deliberately defensive: a malformed or truncated container yields (nil, format) rather than an error, because a missing or unreadable profile is a normal condition that must fall back to the default colour handling, not abort image ingestion.

Index ▾

Package files

iccextract.go jpeg.go png.go tiff.go

type Format

Format identifies the detected image container format.

type Format string

Recognised container formats.

const (
    FormatUnknown Format = ""
    FormatJPEG    Format = "jpeg"
    FormatPNG     Format = "png"
    FormatTIFF    Format = "tiff"
)

func Detect

func Detect(data []byte) Format

Detect sniffs the container format from the leading magic bytes of data. It returns FormatUnknown when data is too short or matches no known format.

func Extract

func Extract(data []byte) (profile []byte, format Format)

Extract detects the container format of data and returns any embedded ICC profile it carries.

A nil profile with a non-empty format means the format was recognised but carries no profile - the common case for web images. Unrecognised input yields (nil, FormatUnknown). A missing or unreadable profile is reported as a nil profile, not an error.