Sha256: 7124967339a4854b47f669d48351cc9ff71c4e1b96daf517ae19c7bcb44381ce

Contents?: true

Size: 761 Bytes

Versions: 13

Compression:

Stored size: 761 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

13 entries across 13 versions & 3 rubygems

Version Path
rmagick-windows-2.16.5 doc/ex/compose_mask.rb
rmagick-windows-2.16.4 doc/ex/compose_mask.rb
rmagick-windows-2.16.3 doc/ex/compose_mask.rb
rmagick-windows-2.16.2 doc/ex/compose_mask.rb
rmagick-windows-2.16.1 doc/ex/compose_mask.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/rmagick-2.16.0/doc/ex/compose_mask.rb
rmagick-2.16.0 doc/ex/compose_mask.rb
rmagick-2.15.4 doc/ex/compose_mask.rb
rmagick-2.15.3 doc/ex/compose_mask.rb
rmagick-2.15.2 doc/ex/compose_mask.rb
rmagick-2.15.1 doc/ex/compose_mask.rb
rmagick-2.15.0 doc/ex/compose_mask.rb
rmagick-2.14.0 doc/ex/compose_mask.rb