Sha256: 3b0e87be04461ca4cf72b8fd27540cc992a128ca00a8372692379f3fd311a2ec

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

module Dragonfly
  module ImageMagick
    module Commands
      module_function

      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

      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dragonfly-1.4.1 lib/dragonfly/image_magick/commands.rb
dragonfly-1.4.0 lib/dragonfly/image_magick/commands.rb