Class Fleximage::Operator::Border
In: lib/fleximage/operator/border.rb
Parent: Operator::Base

Add a border to the outside of the image

  image.border(options = {})

Use the following keys in the options hash:

  • size: Width of the border on each side. You can use a 2 dimensional value (‘5x10’) if you want different widths for the sides and top borders, but a single integer will apply the same border on all sides.
  • color: the color of the border. Use an RMagick named color or use the color method in FlexImage::Controller, or a Magick::Pixel object.

Example:

  @photo.operate do |image|
    # Defaults
    image.border(
      :size  => 10,
      :color => 'white'    # or color(255, 255, 255)
    )

    # Big, pink and wide
    image.border(
      :size  => '200x100',
      :color => color(255, 128, 128)
    )
  end

Methods

operate  

Public Instance methods

[Source]

    # File lib/fleximage/operator/border.rb, line 33
33:       def operate(options = {})
34:         options = options.symbolize_keys if options.respond_to?(:symbolize_keys)
35:         defaults = {
36:           :size => '10',
37:           :color => 'white'
38:         }
39:         options = options.is_a?(Hash) ? defaults.update(options) : defaults
40:         
41:         # Get border size
42:         options[:size] = size_to_xy(options[:size])
43: 
44:         # apply border
45:         @image.border!(options[:size][0], options[:size][1], options[:color])
46:       end

[Validate]