Parent

Files

Class/Module Index [+]

Quicksearch

Dragonfly::ImageMagick::Processor

Public Instance Methods

auto_orient(temp_object) click to toggle source
# File lib/dragonfly/image_magick/processor.rb, line 30
def auto_orient(temp_object)
  convert(temp_object, "-auto-orient")
end
convert(temp_object, args='', format=nil) click to toggle source
# File lib/dragonfly/image_magick/processor.rb, line 108
def convert(temp_object, args='', format=nil)
  format ? [super, {:format => format.to_sym}] : super
end
crop(temp_object, opts={}) click to toggle source
# File lib/dragonfly/image_magick/processor.rb, line 34
def crop(temp_object, opts={})
  opts = Dragonfly::Utils.symbolize_keys(opts)

  width   = opts[:width]
  height  = opts[:height]
  gravity = GRAVITIES[opts[:gravity]]
  x       = "#{opts[:x] || 0}"
  x = '+' + x unless x[/^[+-]/]
  y       = "#{opts[:y] || 0}"
  y = '+' + y unless y[/^[+-]/]
  repage  = opts[:repage] == false ? '' : '+repage'
  resize  = opts[:resize]

  convert(temp_object, "#{"-resize #{resize} " if resize}#{"-gravity #{gravity} " if gravity}-crop #{width}x#{height}#{x}#{y} #{repage}")
end
flip(temp_object) click to toggle source
# File lib/dragonfly/image_magick/processor.rb, line 50
def flip(temp_object)
  convert(temp_object, "-flip")
end
flop(temp_object) click to toggle source
# File lib/dragonfly/image_magick/processor.rb, line 54
def flop(temp_object)
  convert(temp_object, "-flop")
end
grayscale(temp_object) click to toggle source
Alias for: greyscale
greyscale(temp_object) click to toggle source
# File lib/dragonfly/image_magick/processor.rb, line 58
def greyscale(temp_object)
  convert(temp_object, "-colorspace Gray")
end
Also aliased as: grayscale
resize(temp_object, geometry) click to toggle source
# File lib/dragonfly/image_magick/processor.rb, line 26
def resize(temp_object, geometry)
  convert(temp_object, "-resize #{geometry}")
end
resize_and_crop(temp_object, opts={}) click to toggle source
# File lib/dragonfly/image_magick/processor.rb, line 63
def resize_and_crop(temp_object, opts={})
  opts = Dragonfly::Utils.symbolize_keys(opts)

  if !opts[:width] && !opts[:height]
    return temp_object
  elsif !opts[:width] || !opts[:height]
    attrs          = identify(temp_object)
    opts[:width]   ||= attrs[:width]
    opts[:height]  ||= attrs[:height]
  end

  opts[:gravity] ||= 'c'

  opts[:resize]  = "#{opts[:width]}x#{opts[:height]}^^"
  crop(temp_object, opts)
end
rotate(temp_object, amount, opts={}) click to toggle source
# File lib/dragonfly/image_magick/processor.rb, line 80
def rotate(temp_object, amount, opts={})
  opts = Dragonfly::Utils.symbolize_keys(opts)

  convert(temp_object, "-rotate #{amount}#{opts[:qualifier]}")
end
strip(temp_object) click to toggle source
# File lib/dragonfly/image_magick/processor.rb, line 86
def strip(temp_object)
  convert(temp_object, "-strip")
end
thumb(temp_object, geometry) click to toggle source
# File lib/dragonfly/image_magick/processor.rb, line 90
def thumb(temp_object, geometry)
  case geometry
  when RESIZE_GEOMETRY
    resize(temp_object, geometry)
  when CROPPED_RESIZE_GEOMETRY
    resize_and_crop(temp_object, 'width' => $1, 'height' => $2, 'gravity' => $3)
  when CROP_GEOMETRY
    crop(temp_object,
      'width' => $1,
      'height' => $2,
      'x' => $3,
      'y' => $4,
      'gravity' => $5
    )
  else raise ArgumentError, "Didn't recognise the geometry string #{geometry}"
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.