Skip to content

Instantly share code, notes, and snippets.

@uhlenbrock
Last active June 9, 2017 19:36
Show Gist options
  • Save uhlenbrock/e21b2fd1edb0a9b9a2f7767a5f90259b to your computer and use it in GitHub Desktop.
Save uhlenbrock/e21b2fd1edb0a9b9a2f7767a5f90259b to your computer and use it in GitHub Desktop.
Read EXIF data with a Dragonfly Analyzer
require 'dragonfly'
require 'exif_analyser'
Dragonfly.app.configure do
plugin ExifAnalyser.new
end
class ExifAnalyser
def call(app, opts = {})
# OS X: `brew install exiftool`
# Ubuntu: `apt-get libimage-exiftool-perl`
app.env[:exiftool_command] = opts[:exiftool_command] || 'exiftool'
app.define :exif do |*_args|
begin
shell_eval { |path| "#{app.env[:exiftool_command]} -j #{path}" }
rescue Dragonfly::Shell::CommandFailed => e
Dragonfly.debug(e)
nil
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment