Skip to content

Instantly share code, notes, and snippets.

@miharekar
Created August 24, 2021 10:07
Show Gist options
  • Save miharekar/5923ea041b61a58dc509a2042f0e0290 to your computer and use it in GitHub Desktop.
Save miharekar/5923ea041b61a58dc509a2042f0e0290 to your computer and use it in GitHub Desktop.
Copy GPS coordinates of a dropped in photo to clipboard
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