Free Trial
10 days, no credit_card

<< More Tutorials

How to read Exif data in json format from an image in Go using rethumb?

To read Exif data in json format from an image in Go use the following code:

package main

import (
	"fmt";
	"net/http";
	"io/ioutil";
	"encoding/json"
)

func main() {
	resp, err := http.Get("http://api.rethumb.com/v1/exif/all/http://images.rethumb.com/image_exif_1.jpg")
	check(err)
	defer resp.Body.Close()
	
	body, err := ioutil.ReadAll(resp.Body)
	check(err)

	byt := []byte(body)
	var dat map[string]interface{}
	if err := json.Unmarshal(byt, &dat); err != nil {
		panic(err)
	}
	fmt.Println(dat)
}

func check(e error) {
	if e != nil {
		panic(e)
	}
}

Start using this example now

Use the following commands to get started:

$ git clone https://github.com/rethumb/rethumb-go-examples.git
$ cd rethumb-go-examples
$ go build read-exif-data-in-json.go
$ ./read-exif-data-in-json

More examples using Go