Sha256: 940a861dda9bd4e3854b4467c1619004d894f0d77353159eef2ef6e0c2968b65

Contents?: true

Size: 796 Bytes

Versions: 67

Compression:

Stored size: 796 Bytes

Contents

#!/usr/local/bin/ruby -w
require 'RMagick'

# Demonstrate the ImageListImage#quantize method by converting
# a color image into a monochrome image.

# Read the large color cheetah image and scale it to a third
# of its size.
cheetah = Magick::Image.read("images/Cheetah.jpg").first
cheetah.scale!(0.33)

# Quantize the cheetah image into 256 colors in the GRAY colorspace.
mono_cheetah = cheetah.quantize 256, Magick::GRAYColorspace

# Cut the top off the monochrome cheetah image.
mono_bottom = mono_cheetah.crop 0, mono_cheetah.rows/2, mono_cheetah.columns, mono_cheetah.rows/2

# Composite the half-height mono cheetah onto the bottom of
# the original color cheetah.
before_after = cheetah.composite mono_bottom, 0, cheetah.rows/2, Magick::OverCompositeOp

before_after.write "mono.jpg"
exit

Version data entries

67 entries across 67 versions & 2 rubygems

Version Path
rmagick-2.13.4 doc/ex/mono.rb
rmagick-2.13.3 doc/ex/mono.rb
rmagick-2.13.3.rc1 doc/ex/mono.rb
rmagick-2.13.2 doc/ex/mono.rb
rdp-rmagick-0.0.0 doc/ex/mono.rb
rmagick-2.13.1 doc/ex/mono.rb
rmagick-2.12.2 doc/ex/mono.rb
rmagick-2.12.1 doc/ex/mono.rb
rmagick-2.12.0 doc/ex/mono.rb
rmagick-2.11.1 doc/ex/mono.rb
rmagick-2.10.0 doc/ex/mono.rb
rmagick-2.11.0 doc/ex/mono.rb
rmagick-1.10.0 doc/ex/mono.rb
rmagick-1.10.1 doc/ex/mono.rb
rmagick-1.13.0 doc/ex/mono.rb
rmagick-1.12.0 doc/ex/mono.rb
rmagick-1.11.1 doc/ex/mono.rb
rmagick-1.11.0 doc/ex/mono.rb
rmagick-1.15.0 doc/ex/mono.rb
rmagick-1.14.1 doc/ex/mono.rb