Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image: RegisterImage can't be taught to detect Targa images #6691

Closed
gopherbot opened this issue Oct 30, 2013 · 7 comments
Closed

image: RegisterImage can't be taught to detect Targa images #6691

gopherbot opened this issue Oct 30, 2013 · 7 comments

Comments

@gopherbot
Copy link

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.
@vdobler
Copy link
Contributor

vdobler commented Oct 30, 2013

Comment 1:

The footer ends in "TRUEVISION-XFILE.\x00" only for version 2
of the file format and even for version 2 this footer is 
optional. Maybe targa files are just to bad for a simple
solution?

@robpike
Copy link
Contributor

robpike commented Oct 30, 2013

Comment 2:

Status changed to Thinking.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 3:

Labels changed: added go1.3maybe.

@dsymonds
Copy link
Contributor

dsymonds commented Dec 2, 2013

Comment 4:

Labels changed: added priority-someday, packagechange, removed priority-triage.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 5:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 6:

Labels changed: added repo-main.

@nigeltao
Copy link
Contributor

Comment 7:

I don't have data, but I feel like TARGA images are relatively rare (and the format was
designed in a time when images were typically files on disk instead of streamed over the
network), so while there would be a benefit to this, I don't think that the benefits
outweight the complexity costs.
You are of course free to implement your own Decode(io.ReadSeeker) function in your own
package, or if you know that you're dealing with a .tga file, you could call
targa.Decode directly.

Labels changed: removed priority-someday, packagechange.

Status changed to WorkingAsIntended.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants