Skip to content
This repository
Browse code

Merge pull request #7 from leeh/master

Support exiftool -c option for formatting GPS coordinates.
  • Loading branch information...
commit a6d5a102af6a8aa13699839f19832716314d7f20 2 parents a4eb504 + c503117
janfri authored April 22, 2013
2  lib/mini_exiftool.rb
@@ -56,6 +56,7 @@ def initialize filename=nil, opts={}
56 56
     @convert_encoding = opts[:convert_encoding]
57 57
     @ignore_minor_errors = opts[:ignore_minor_errors]
58 58
     @timestamps = opts[:timestamps]
  59
+    @coord_format = opts[:coord_format]
59 60
     @values = TagHash.new
60 61
     @tag_names = TagHash.new
61 62
     @changed_values = TagHash.new
@@ -88,6 +89,7 @@ def load filename
88 89
     opt_params << (@numerical ? '-n ' : '')
89 90
     opt_params << (@composite ? '' : '-e ')
90 91
     opt_params << (@convert_encoding ? '-L ' : '')
  92
+    opt_params << (@coord_format ? "-c \"#{@coord_format}\"" : '')
91 93
     cmd = %Q(#@@cmd -q -q -s -t #{opt_params} #{@@sep_op} #{Shellwords.escape(filename)})
92 94
     if run(cmd)
93 95
       parse_output
BIN  test/data/test_coordinates.jpg
18  test/test_read_coordinates.rb
... ...
@@ -0,0 +1,18 @@
  1
+# -- encoding: utf-8 --
  2
+require 'helpers_for_test'
  3
+
  4
+class TestReadCoordinates < TestCase
  5
+
  6
+  def setup
  7
+    @data_dir = File.dirname(__FILE__) + '/data'
  8
+    @filename_test = @data_dir + '/test_coordinates.jpg'
  9
+  end
  10
+
  11
+  def test_access_coordinates
  12
+    mini_exiftool_coord = MiniExiftool.new @filename_test, :coord_format => "%+.6f"
  13
+    assert_equal '+43.653167', mini_exiftool_coord['GPSLatitude']
  14
+    assert_equal '-79.373167', mini_exiftool_coord['GPSLongitude']
  15
+    assert_equal '+43.653167, -79.373167', mini_exiftool_coord['GPSPosition']
  16
+  end
  17
+
  18
+end

0 notes on commit a6d5a10

Please sign in to comment.
Something went wrong with that request. Please try again.