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: Decode unknown format on jpeg (forgot to import "image/jpeg") #9184

Closed
gopherbot opened this issue Dec 1, 2014 · 3 comments
Closed

image: Decode unknown format on jpeg (forgot to import "image/jpeg") #9184

gopherbot opened this issue Dec 1, 2014 · 3 comments

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 1, 2014

by franklin@krave-n.com:

Below is a test program that illustrates the problem if applied against the attached
jpeg.

_, _, err := image.Decode(rdr)

"error image: unknown format"


---------------------------
package main

import (
    "bufio"
    "fmt"
    "image"
    "net/http"
    "os"
)

func main() {
    file, _ := os.Open("tryme.jpeg")
    defer file.Close()
    rdr := bufio.NewReader(file)
    bts, _ := rdr.Peek(512)
    contentType := http.DetectContentType(bts)
    fmt.Println(contentType)
    _, _, err := image.Decode(rdr)
    if err != nil {
        fmt.Println("error " + err.Error())

    }
    fmt.Println("done")
}

Attachments:

  1. tryme.jpeg (2594 bytes)
@minux
Copy link
Member

@minux minux commented Dec 1, 2014

Comment 2:

You forgot to add
import _ "image/jpeg"
the image package itself doesn't know how to decode jpeg, you need to
import image/jpeg to register the jpeg decoder.

Labels changed: added repo-main.

Status changed to WorkingAsIntended.

Loading

@gopherbot
Copy link
Author

@gopherbot gopherbot commented Dec 2, 2014

Comment 3 by franklin@krave-n.com:

Ok, yes, you are correct.

Loading

@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants