LoginSignup
4
4

More than 5 years have passed since last update.

Goで写真のExifを読み取る方法(位置情報)

Last updated at Posted at 2015-01-05

目的

 uploadされた写真のExif内から位置情報を取り出して表示する

環境

Go version 1.3.1

準備

ほぼこちらです。
https://godoc.org/github.com/rwcarlsen/goexif/exif
事前準備として以下を実行しておきましょう

go get github.com/rwcarlsen/goexif/exif

これで準備完了です。

概要

 ファイルをOpenして、サンプルの通り実行しています。非常に簡単です。

ソースコードと詳細説明

sample.go
package main

import (
    "github.com/rwcarlsen/goexif/exif"
    "os"
)

// main
func main() {

    frame := "sample.jpg"
    file, err := os.Open(frame)
    if err != nil {
        panic(err)
    }

    x, err := exif.Decode(file)
    if err != nil {
        panic(err)
    }

    lat, lng, _ := x.LatLong()
    println(lat, lng)
}

このような、ライブラリーを手早く使えるのがGoの好きなところです。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4