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

Comments

@gopherbot
Copy link

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 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.

@gopherbot
Copy link
Author

Comment 3 by franklin@krave-n.com:

Ok, yes, you are correct.

@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

2 participants