Sha256: 4d993852cd39b85f5585b6182e46bd776a4fefd1da2a7f2d0746f7a8c522939b
Contents?: true
Size: 796 Bytes
Versions: 6
Compression:
Stored size: 796 Bytes
Contents
#!/usr/bin/env ruby -w require 'rmagick' # Demonstrate the Image#crop method img = Magick::Image.read('images/Flower_Hat.jpg')[0] # Crop the specified rectangle out of the img. chopped = img.crop(23, 81, 107, 139) # Go back to the original and highlight the area # corresponding to the retained rectangle. rect = Magick::Draw.new rect.stroke('transparent') rect.fill('white') rect.fill_opacity(0.25) rect.rectangle(23, 81, 107 + 23, 139 + 81) rect.draw(img) img.write('crop_before.png') # Create a image to use as a background for # the "after" image. bg = Magick::Image.new(img.columns, img.rows) { self.background_color = 'none' } # Composite the the "after" (chopped) image on the background bg = bg.composite(chopped, 23, 81, Magick::OverCompositeOp) bg.write('crop_after.png') exit
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
rmagick-4.1.0.rc2 | doc/ex/crop.rb |
rmagick-4.1.0.rc1 | doc/ex/crop.rb |
rmagick-4.0.0 | doc/ex/crop.rb |
rmagick-3.2.0 | doc/ex/crop.rb |
rmagick-3.1.0 | doc/ex/crop.rb |
rmagick-3.0.0 | doc/ex/crop.rb |