var ErrFormat … type format … var formatsMu … var atomicFormats … // RegisterFormat registers an image format for use by [Decode]. // Name is the name of the format, like "jpeg" or "png". // Magic is the magic prefix that identifies the format's encoding. The magic // string can contain "?" wildcards that each match any one byte. // [Decode] is the function that decodes the encoded image. // [DecodeConfig] is the function that decodes just its configuration. func RegisterFormat(name, magic string, decode func(io.Reader) (Image, error), decodeConfig func(io.Reader) (Config, error)) { … } type reader … // asReader converts an io.Reader to a reader. func asReader(r io.Reader) reader { … } // match reports whether magic matches b. Magic may contain "?" wildcards. func match(magic string, b []byte) bool { … } // sniff determines the format of r's data. func sniff(r reader) format { … } // Decode decodes an image that has been encoded in a registered format. // The string returned is the format name used during format registration. // Format registration is typically done by an init function in the codec- // specific package. func Decode(r io.Reader) (Image, string, error) { … } // DecodeConfig decodes the color model and dimensions of an image that has // been encoded in a registered format. The string returned is the format name // used during format registration. Format registration is typically done by // an init function in the codec-specific package. func DecodeConfig(r io.Reader) (Config, string, error) { … }