Sha256: 810e289a2afd807daf9df1d7cdefe244639c35d3031d0c063feb21eeff0f2916

Contents?: true

Size: 614 Bytes

Versions: 38

Compression:

Stored size: 614 Bytes

Contents

require 'RMagick'
include Magick

# Demonstrate the trim method

# Read the Flower_Hat image and reduce it to 80% of its original size.
img = Image.read('images/Flower_Hat.jpg').first
cols = img.columns
rows = img.rows
img.resize!(0.80)

# Add a gray border to bring it back up to size
before = img.border((cols-img.columns)/2, (rows-img.rows)/2, '#999')

# Trim away the gray border
after = before.trim

# Add a white border to bring it back up to size
after.border!((cols-img.columns)/2, (rows-img.rows)/2, 'white')

# Need GIF for tranparency
before.write('trim_before.jpg')
after.write('trim_after.jpg')
exit

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
rmagick-1.10.0 doc/ex/trim.rb
rmagick-1.10.1 doc/ex/trim.rb
rmagick-1.12.0 doc/ex/trim.rb
rmagick-1.13.0 doc/ex/trim.rb
rmagick-1.11.0 doc/ex/trim.rb
rmagick-1.11.1 doc/ex/trim.rb
rmagick-1.15.1 doc/ex/trim.rb
rmagick-1.14.1 doc/ex/trim.rb
rmagick-1.14.0 doc/ex/trim.rb
rmagick-1.15.0 doc/ex/trim.rb
rmagick-1.15.10 doc/ex/trim.rb
rmagick-1.15.14 doc/ex/trim.rb
rmagick-1.15.11 doc/ex/trim.rb
rmagick-1.15.12 doc/ex/trim.rb
rmagick-1.15.13 doc/ex/trim.rb
rmagick-1.15.15 doc/ex/trim.rb
rmagick-1.15.3 doc/ex/trim.rb
rmagick-1.15.16 doc/ex/trim.rb
rmagick-1.15.17 doc/ex/trim.rb
rmagick-1.15.2 doc/ex/trim.rb