Sha256: 6ba37e778ca8350dd83eb3d7a1b12c8c47b921cabf5a45b0def2ea98a552cfdf
Contents?: true
Size: 759 Bytes
Versions: 58
Compression:
Stored size: 759 Bytes
Contents
#!/usr/local/bin/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.jpg') # Create a image to use as a background for # the "after" image. bg = Magick::Image.new(img.columns, img.rows) # Composite the the "after" (chopped) image on the background bg = bg.composite(chopped, 23, 81, Magick::OverCompositeOp) bg.write('crop_after.jpg') exit
Version data entries
58 entries across 58 versions & 1 rubygems