Skip to content

Instantly share code, notes, and snippets.

@rafapolo
Created April 28, 2016 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafapolo/532dee891e4ef6422e12a0a0fb1d3546 to your computer and use it in GitHub Desktop.
Save rafapolo/532dee891e4ef6422e12a0a0fb1d3546 to your computer and use it in GitHub Desktop.
read exif metadata from uploaded pics on the browser
require 'sinatra'
set :port, 8080
set :bind, '0.0.0.0'
get "/" do
erb :index
end
get '/get_exif' do
"Upload an image."
end
post '/get_exif' do
@filename = params[:file][:filename]
file = params[:file][:tempfile]
path = "./tmp/#{@filename}"
File.open(path, 'wb') do |f|
f.write(file.read)
end
@exif = `exiftool #{path}`
`rm #{path}`
erb :exif
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment