Module: Dragonfly::ImageMagick::Commands

Defined in:
lib/dragonfly/image_magick/commands.rb

Class Method Summary collapse

Class Method Details

.convert(content, args = "", opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dragonfly/image_magick/commands.rb', line 6

def convert(content, args = "", opts = {})
  convert_command = content.env[:convert_command] || "convert"
  format = opts["format"]

  input_args = opts["input_args"] if opts["input_args"]
  delegate_string = "#{opts["delegate"]}:" if opts["delegate"]
  frame_string = "[#{opts["frame"]}]" if opts["frame"]

  content.shell_update :ext => format do |old_path, new_path|
    "#{convert_command} #{input_args} #{delegate_string}#{old_path}#{frame_string} #{args} #{new_path}"
  end

  if format
    content.meta["format"] = format.to_s
    content.ext = format
    content.meta["mime_type"] = nil # don't need it as we have ext now
  end
end

.generate(content, args, format) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/dragonfly/image_magick/commands.rb', line 25

def generate(content, args, format)
  format = format.to_s
  convert_command = content.env[:convert_command] || "convert"
  content.shell_generate :ext => format do |path|
    "#{convert_command} #{args} #{path}"
  end
  content.add_meta("format" => format)
end