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.4.0'

Instance Method Summary collapse

Instance Method Details

#generate_thumb(options = {}) ⇒ Object

Raises:

  • (Errno::ENOENT)


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/miniatura.rb', line 8

def generate_thumb(options = {})
  @exit_code, @error = nil
  raise Errno::ENOENT unless File.exist?(current_path)
  options[:file_extension] ||= 'jpeg'
  options[:rotate] = 0
  options[:size] = determine_thumb_dimension_ratio_from_uploaded_video(options[:size])
  tmp_path = generate_temp_file(options[:file_extension])
  cmd = generate_command_for_thumbnail(options, tmp_path)
  show_logs(cmd)
  execute_command(cmd)
  handle_exit_code(@exit_code, @error)
  File.rename tmp_path, current_path
end