Sha256: abbeb2a9c06c8d3e421eb747b8a63b988477fd2bbfc1e59e970e8b0f7b4a4ff7

Contents?: true

Size: 607 Bytes

Versions: 29

Compression:

Stored size: 607 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

29 entries across 29 versions & 2 rubygems

Version Path
rmagick-2.13.4 doc/ex/trim.rb
rmagick-2.13.3 doc/ex/trim.rb
rmagick-2.13.3.rc1 doc/ex/trim.rb
rmagick-2.13.2 doc/ex/trim.rb
rdp-rmagick-0.0.0 doc/ex/trim.rb
rmagick-2.13.1 doc/ex/trim.rb
rmagick-2.12.2 doc/ex/trim.rb
rmagick-2.12.1 doc/ex/trim.rb
rmagick-2.12.0 doc/ex/trim.rb
rmagick-2.11.1 doc/ex/trim.rb
rmagick-2.10.0 doc/ex/trim.rb
rmagick-2.11.0 doc/ex/trim.rb
rmagick-2.2.0 doc/ex/trim.rb
rmagick-2.3.0 doc/ex/trim.rb
rmagick-2.0.0 doc/ex/trim.rb
rmagick-2.1.0 doc/ex/trim.rb
rmagick-2.2.2 doc/ex/trim.rb
rmagick-2.5.2 doc/ex/trim.rb
rmagick-2.5.1 doc/ex/trim.rb
rmagick-2.4.0 doc/ex/trim.rb