Sha256: 7f44b7100d7d2bc661ecd4617c91890143a8517ed1ae4ad581c1de9dae12ced8

Contents?: true

Size: 762 Bytes

Versions: 23

Compression:

Stored size: 762 Bytes

Contents

require 'RMagick'

background = Magick::Image.read('images/Flower_Hat.jpg').first
source = Magick::Image.read('pattern:checkerboard') {self.size = "#{background.columns}x#{background.rows}"}.first
mask = Magick::Image.new(background.columns, background.rows) {self.background_color = "black"}

# Make a mask
gc = Magick::Draw.new
gc.annotate(mask, 0, 0, 0, 0, "Ruby") do
  gc.gravity = Magick::CenterGravity
  gc.pointsize = 100
  gc.rotation = 90
  gc.font_weight = Magick::BoldWeight
  gc.fill = "white"
  gc.stroke = "none"
end

background.add_compose_mask(mask)
result = background.composite(source, Magick::CenterGravity, Magick::OverCompositeOp)
result.write "compose_mask_example.jpg"
source.write "compose_mask_source.gif"
mask.write "compose_mask.gif"

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
rmagick-2.13.4 doc/ex/compose_mask.rb
rmagick-2.13.3 doc/ex/compose_mask.rb
rmagick-2.13.3.rc1 doc/ex/compose_mask.rb
rmagick-2.13.2 doc/ex/compose_mask.rb
rdp-rmagick-0.0.0 doc/ex/compose_mask.rb
rmagick-2.13.1 doc/ex/compose_mask.rb
rmagick-2.12.2 doc/ex/compose_mask.rb
rmagick-2.12.1 doc/ex/compose_mask.rb
rmagick-2.12.0 doc/ex/compose_mask.rb
rmagick-2.11.1 doc/ex/compose_mask.rb
rmagick-2.10.0 doc/ex/compose_mask.rb
rmagick-2.11.0 doc/ex/compose_mask.rb
rmagick-2.6.0 doc/ex/compose_mask.rb
rmagick-2.5.0 doc/ex/compose_mask.rb
rmagick-2.5.1 doc/ex/compose_mask.rb
rmagick-2.5.2 doc/ex/compose_mask.rb
rmagick-2.7.0 doc/ex/compose_mask.rb
rmagick-2.7.1 doc/ex/compose_mask.rb
rmagick-2.7.2 doc/ex/compose_mask.rb
rmagick-2.8.0 doc/ex/compose_mask.rb