Class: Fleximage::Operator::Border
- Defined in:
- lib/fleximage/operator/border.rb
Overview
Add a border to the outside of the image
image.border( = {})
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 thecolor
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
Instance Method Summary collapse
Methods inherited from Base
#color, color, #execute, #initialize, #scale, #scale_and_crop, size_to_xy, #size_to_xy, #stretch, #symbol_to_blending_mode, #symbol_to_gravity
Constructor Details
This class inherits a constructor from Fleximage::Operator::Base
Instance Method Details
#operate(options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fleximage/operator/border.rb', line 33 def operate( = {}) = .symbolize_keys if .respond_to?(:symbolize_keys) defaults = { :size => '10', :color => 'white' } = .is_a?(Hash) ? defaults.update() : defaults # Get border size [:size] = size_to_xy([:size]) # apply border @image.border!([:size][0], [:size][1], [:color]) end |