-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Closed
Labels
Description
by jeff.allen:
Targa files end with "54 52 55 45 56 49 53 49 4f 4e 2d 58 46 49 4c 45
2e 00".
The detection mechanism in package images can't handle this, because it only looks at
the beginning of files.
A solution might be to provide a new registration function like:
package image
func RegisterDetector(name string, detect func(io.ReaderSeeker) bool, decode func(io.Reader) (Image, error), decodeConfig func(io.Reader) (Config, error))
RegisterFormat could be reimplemented as a call to RegisterDetector that constructs the
correct lambda to do the string matching on the front of the file.
The docs should encourage continued use of RegisterFormat, because it only requires an
io.Reader, not the more {complex,rare,memory-hungry} io.ReaderSeeker.
As a backwards compatible addition to the API, this could be done in Go 1.x, but I
wouldn't be shocked if you just marked this as a wishlist item for Go 2.