aboutsummaryrefslogtreecommitdiff
path: root/src/image
diff options
context:
space:
mode:
authorAarti Parikh <aarti.parikh@gmail.com>2018-05-29 00:42:10 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2018-05-29 03:16:17 +0000
commit5c36fdfd39e231e87b267fc718c9fd6a86f49b90 (patch)
treee247a4bacf36db9f567565cd59808d4c83bf1b6f /src/image
parent33cfcf6afac867f4fbf94237b9219778e5fd51c7 (diff)
downloadgo-5c36fdfd39e231e87b267fc718c9fd6a86f49b90.tar.gz
go-5c36fdfd39e231e87b267fc718c9fd6a86f49b90.zip
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 PR will be imported into Gerrit with the title and first comment (this text) used to generate the subject and body of the Gerrit change. Change-Id: Idca527d97c095af88755446e1548fa2b8ace7eb0 GitHub-Last-Rev: f5743c8ef337a8b7a5126db21d784593f4f53c8a GitHub-Pull-Request: golang/go#25616 Reviewed-on: https://go-review.googlesource.com/114939 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/image')
-rw-r--r--src/image/decode_example_test.go9
1 files changed, 9 insertions, 0 deletions
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
//