Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Support for exiftool -c option for formatting GPS coordinates

  • Loading branch information...
commit c503117689f6ba7ae9c20043e1f43fd1fc0068b4 1 parent a4eb504
Lee Horrocks leeh authored
2  lib/mini_exiftool.rb
View
@@ -56,6 +56,7 @@ def initialize filename=nil, opts={}
@convert_encoding = opts[:convert_encoding]
@ignore_minor_errors = opts[:ignore_minor_errors]
@timestamps = opts[:timestamps]
+ @coord_format = opts[:coord_format]
@values = TagHash.new
@tag_names = TagHash.new
@changed_values = TagHash.new
@@ -88,6 +89,7 @@ def load filename
opt_params << (@numerical ? '-n ' : '')
opt_params << (@composite ? '' : '-e ')
opt_params << (@convert_encoding ? '-L ' : '')
+ opt_params << (@coord_format ? "-c \"#{@coord_format}\"" : '')
cmd = %Q(#@@cmd -q -q -s -t #{opt_params} #{@@sep_op} #{Shellwords.escape(filename)})
if run(cmd)
parse_output
BIN  test/data/test_coordinates.jpg
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 test/test_read_coordinates.rb
View
@@ -0,0 +1,18 @@
+# -- encoding: utf-8 --
+require 'helpers_for_test'
+
+class TestReadCoordinates < TestCase
+
+ def setup
+ @data_dir = File.dirname(__FILE__) + '/data'
+ @filename_test = @data_dir + '/test_coordinates.jpg'
+ end
+
+ def test_access_coordinates
+ mini_exiftool_coord = MiniExiftool.new @filename_test, :coord_format => "%+.6f"
+ assert_equal '+43.653167', mini_exiftool_coord['GPSLatitude']
+ assert_equal '-79.373167', mini_exiftool_coord['GPSLongitude']
+ assert_equal '+43.653167, -79.373167', mini_exiftool_coord['GPSPosition']
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.