Skip to content

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

Description

@gopherbot

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions