Sha256: e02799994384a11e89251a902e9aeb6900cc46c0da7b315d78b81ef8a84e9740

Contents?: true

Size: 606 Bytes

Versions: 13

Compression:

Stored size: 606 Bytes

Contents

require 'rmagick'

# Demonstrate the trim method

# Read the Flower_Hat image and reduce it to 80% of its original size.
img = Magick::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

13 entries across 13 versions & 3 rubygems

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