Module: Miniatura
- Defined in:
- lib/miniatura.rb,
lib/miniatura/logger.rb,
lib/miniatura/options.rb,
lib/miniatura/version.rb,
lib/miniatura/generate_command.rb
Defined Under Namespace
Classes: GenerateCommand, Logger, Options
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
Instance Method Details
#generate_thumb(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/miniatura.rb', line 9 def generate_thumb = {} [:file_extension] ||= 'jpeg' [:logger] = Rails.logger [:rotate] = 0 # options[:rotate] # p video = MiniExiftool.new(current_path) # p "before" # p options # p orientation = video.rotation # case orientation # when 0 # options[:rotate] = 0 # when 90 # options[:rotate] = 0 # when 180 # options[:rotate] = 180 # end # p "after" p tmp_path = File.join( File.dirname(current_path), "tmpfile.#{options[:file_extension]}") thumbnail = GenerateCommand.new(current_path, tmp_path) cmd = thumbnail.generate_command() logger = Miniatura::Logger.new().logger logger.info("Running command: #{cmd}") exit_code, error = nil raise Errno::ENOENT unless File.exist?(current_path) Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr| error = stderr.read exit_code = wait_thr.value end handle_exit_code(exit_code, error, logger) File.rename tmp_path, current_path end |