From f5743c8ef337a8b7a5126db21d784593f4f53c8a Mon Sep 17 00:00:00 2001 From: Aarti Parikh Date: Mon, 28 May 2018 17:12:50 -0700 Subject: [PATCH] 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. --- src/image/decode_example_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/image/decode_example_test.go b/src/image/decode_example_test.go index 81fa0378e1..526c03f3c1 100644 --- a/src/image/decode_example_test.go +++ b/src/image/decode_example_test.go @@ -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 //