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/png: invalid format: palette index out of range #4319

Closed
gopherbot opened this issue Oct 31, 2012 · 6 comments
Closed

image/png: invalid format: palette index out of range #4319

gopherbot opened this issue Oct 31, 2012 · 6 comments
Milestone

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 31, 2012

by darkgray:

What steps will reproduce the problem?
1. Import image/png
2. Attempt to use image.Decode() on certain PNG files
3. Observe error message
Code example (and image) - http://play.golang.org/p/cfi12UMcMR

What is the expected output?
(0,0)-(822,469)

What do you see instead?
2012/10/31 01:59:54 png: invalid format: palette index out of range
exit status 1

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Windows 7

Which version are you using?  (run 'go version')
1.0.3

Please provide any additional information below.
The image attached is an example of error-inducing data. It opens fine in software like
Firefox, Chrome and IrfanView, so it would be nice to make it usable in Go as well.

Attachments:

  1. packetloss.png (11202 bytes)
@robpike
Copy link
Contributor

@robpike robpike commented Oct 31, 2012

Comment 1:

Labels changed: added priority-soon, removed priority-triage.

Owner changed to @nigeltao.

Status changed to Accepted.

@gopherbot
Copy link
Author

@gopherbot gopherbot commented Oct 31, 2012

Comment 3 by jsummers3456:

Firefox makes the undefined pixels black. ImageMagick makes them white (i.e. the first
color in the palette). The PNG spec says the file is invalid. What should Go do?
@minux
Copy link
Member

@minux minux commented Oct 31, 2012

Comment 4:

i think this is WorkingAsIntended.
@gopherbot
Copy link
Author

@gopherbot gopherbot commented Oct 31, 2012

Comment 5 by darkgray:

That's a pretty sad approach. Suppose someone in the future wanted to write an image
editor. Should they just throw away a ton of possible openable images simply because Go
can't be bothered to parse them? At least make an alternative "MustDecode" version or
something.
@minux
Copy link
Member

@minux minux commented Oct 31, 2012

Comment 6:

then how do we draw the line between acceptable and unacceptable images?
there will be tons of type of invalid images, how should we treat them?
i argue that whatever we do with them, the user needs a control, and that
unnecessarily complicates the API.
i think if you want to write an image editor, and specifically want to deal with
bad images, you definitely should apply an extra correction step to them
before feeding them to the image package.
that said, if we provide an API to retrieve the metadata of an image without
parsing them, we can accept images with this kind of defeats.
will let nigel to decide.
@nigeltao
Copy link
Contributor

@nigeltao nigeltao commented Nov 1, 2012

Comment 7:

This issue was closed by revision de6bf20.

Status changed to Fixed.

@gopherbot gopherbot added fixed labels Nov 1, 2012
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.