Sha256: d9d6491b624c6cf87fc4cc0afb8f94459f2d66ebda1e546438799b40bf2d8cd1

Contents?: true

Size: 771 Bytes

Versions: 13

Compression:

Stored size: 771 Bytes

Contents

#!/usr/bin/env ruby -w
require 'rmagick'

# Demonstrate the Image#chop method

img = Magick::Image.read('images/Flower_Hat.jpg')[0]

# Chop the specified rectangle out of the img.
chopped = img.chop(0, img.rows/2, img.columns/2, img.rows)

# Make a "before" image by highlighting the chopped area.
gc = Magick::Draw.new
gc.fill('white')
gc.stroke('transparent')
gc.fill_opacity(0.25)
gc.rectangle(0, img.rows/2, img.columns/2, img.rows)
gc.draw(img)

img.write('chop_before.jpg')

# Create a image to use as a background for
# the after image. Make the chopped image the
# same size as before the chop.
bg = Magick::Image.new(img.columns, img.rows)

chopped = bg.composite(chopped, Magick::NorthEastGravity, Magick::OverCompositeOp)

chopped.write('chop_after.jpg')
exit

Version data entries

13 entries across 13 versions & 3 rubygems

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