Skip to content

Instantly share code, notes, and snippets.

@watanabeyu
Last active April 3, 2018 03:00
Show Gist options
  • Save watanabeyu/d7b4ac8bb6e3e616c09a6a0aecf34401 to your computer and use it in GitHub Desktop.
Save watanabeyu/d7b4ac8bb6e3e616c09a6a0aecf34401 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"image"
_ "image/jpeg"
_ "image/png"
"log"
"net/http"
)
func main() {
response, err := http.Get("https://golang.org/doc/gopher/doc.png")
if err != nil {
panic(err)
}
defer response.Body.Close()
conf, _, err := image.DecodeConfig(response.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Width=%d, Height=%d\n", conf.Width, conf.Height)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment