Sha256: 68f744f073900d58ccfddbd610095654bd86e57f0cf3737994b632e28aa2ab9f

Contents?: true

Size: 773 Bytes

Versions: 67

Compression:

Stored size: 773 Bytes

Contents

#!/usr/local/bin/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

67 entries across 67 versions & 2 rubygems

Version Path
rmagick-2.13.4 doc/ex/chop.rb
rmagick-2.13.3 doc/ex/chop.rb
rmagick-2.13.3.rc1 doc/ex/chop.rb
rmagick-2.13.2 doc/ex/chop.rb
rdp-rmagick-0.0.0 doc/ex/chop.rb
rmagick-2.13.1 doc/ex/chop.rb
rmagick-2.12.2 doc/ex/chop.rb
rmagick-2.12.1 doc/ex/chop.rb
rmagick-2.12.0 doc/ex/chop.rb
rmagick-2.11.1 doc/ex/chop.rb
rmagick-2.10.0 doc/ex/chop.rb
rmagick-2.11.0 doc/ex/chop.rb
rmagick-1.10.1 doc/ex/chop.rb
rmagick-1.10.0 doc/ex/chop.rb
rmagick-1.12.0 doc/ex/chop.rb
rmagick-1.11.1 doc/ex/chop.rb
rmagick-1.11.0 doc/ex/chop.rb
rmagick-1.13.0 doc/ex/chop.rb
rmagick-1.14.1 doc/ex/chop.rb
rmagick-1.14.0 doc/ex/chop.rb