Sha256: 72a09bb7b705f3929c26ddbdc9e311eb3cd25ae1b509c8fefb481b9449897f5e

Contents?: true

Size: 794 Bytes

Versions: 13

Compression:

Stored size: 794 Bytes

Contents

#!/usr/bin/env 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

13 entries across 13 versions & 3 rubygems

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