1
0
mirror of https://github.com/golang/go synced 2024-09-30 08:18:40 -06:00

image: add an example that shows how to get the metadata of an image

This is a simple but everyday use case in image libraries. Currently,
there is one example in this library and it is lengthy and involved.
This commit is contained in:
Aarti Parikh 2018-05-28 17:12:50 -07:00
parent 6070e432d2
commit f5743c8ef3

View File

@ -21,6 +21,15 @@ import (
_ "image/jpeg"
)
func Example_decodeConfig() {
reader := base64.NewDecoder(base64.StdEncoding, strings.NewReader(data))
config, format, err := image.DecodeConfig(reader)
if err != nil {
log.Fatal(err)
}
fmt.Println("Width:", config.Width, "Height:", config.Height, "Format:", format)
}
func Example() {
// Decode the JPEG data. If reading from file, create a reader with
//