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(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(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.