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/gif: Can’t decode gifs that the browser handles #9856

Closed
tessr opened this issue Feb 12, 2015 · 4 comments
Closed

image/gif: Can’t decode gifs that the browser handles #9856

tessr opened this issue Feb 12, 2015 · 4 comments
Milestone

Comments

@tessr
Copy link

tessr commented Feb 12, 2015

There are images which browsers can render but which image/gif chokes on.

The following runs successfully for most gifs:

import (
    "fmt"
    "image/gif"
    "os"
)

const example = "sample.gif"

func main() {
    fmt.Println("attempting to read gif")

    file, err := os.Open(example)
    if err != nil {
        fmt.Println("Can't open this file:", err)
        return
    }

    img, err := gif.Decode(file)
    if err != nil {
        fmt.Println("Can't decode this as a gif:", err)
        return
    }

    _ = img.Bounds()

    fmt.Println("gif decoded")
}

But when trying to run it on a particular gif (below), this happens:

$ go run main.go
attempting to read gif
Can't decode this as a gif: gif: not enough image data

Here’s the offending gif:
sample

Meanwhile, when I run this on another (similar) gif, I get the following:

$ go run main.go
attempting to read gif
Can't decode this as a gif: gif: too much image data

test

It seems like something might be wrong with these gifs, but browsers are still able to read them, so it seems that image/gif should be able to as well.

Tested with both 1.3 and 1.4.

@bradfitz bradfitz added this to the Go1.5 milestone Feb 12, 2015
@bradfitz
Copy link
Contributor

@nigeltao, all yours. As a bonus, you get to learn about the nuclear force interaction while you fix it.

@sbinet
Copy link
Member

sbinet commented Feb 12, 2015

also known as the strong force. (padawan-puns in the CL allowed?)

@gopherbot
Copy link

CL https://golang.org/cl/11661 mentions this issue.

@gopherbot
Copy link

CL https://golang.org/cl/11663 mentions this issue.

nigeltao added a commit that referenced this issue Jun 30, 2015
This is needed by issue #9856.

Change-Id: Idad570a7e55ad903aab55372d390bc746c4e19cf
Reviewed-on: https://go-review.googlesource.com/11661
Reviewed-by: Rob Pike <r@golang.org>
@golang golang locked and limited conversation to collaborators Jun 29, 2016
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

5 participants