Created
August 24, 2021 10:07
-
-
Save miharekar/5923ea041b61a58dc509a2042f0e0290 to your computer and use it in GitHub Desktop.
Copy GPS coordinates of a dropped in photo to clipboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loop do | |
puts "Gimme photo\n" | |
path = gets | |
exifdata = value = `exiftool -c "%+.10f" #{path} ` | |
line = exifdata.split("\n").find{|l| l.include?("GPS Position")} | |
if line.nil? | |
puts exifdata | |
puts "\nNO GPS 🤷♂️" | |
else | |
coords = line[/: (.*)/, 1] | |
puts "\nCopying #{coords} to clipboard" | |
coords.split(", ").reverse.each do |c| | |
IO.popen('pbcopy', 'w') { |f| f << c } | |
sleep(0.5) | |
end | |
IO.popen('pbcopy', 'w') { |f| f << coords } | |
end | |
puts "\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment