mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00: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 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: f5743c8ef3
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>
This commit is contained in:
parent
33cfcf6afa
commit
5c36fdfd39
|
@ -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
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue