Sha256: a82e35d65ff536ca3794e57ed0344db6b96f9d3060cd3dd2aca054089459fd94

Contents?: true

Size: 1.25 KB

Versions: 18

Compression:

Stored size: 1.25 KB

Contents

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

# Demonstrate the Image#level_channel method

before = Magick::Image.read('images/Flower_Hat.jpg').first

# Let the final argument default
begin
    red   = before.level_channel(Magick::RedChannel,  Magick::MaxRGB, 2)
    green = before.level_channel(Magick::GreenChannel,Magick::MaxRGB, 2)
    blue  = before.level_channel(Magick::BlueChannel, Magick::MaxRGB, 2)

    # Composite the green image over the middle of the red image.
    # Composite the blue image over the right-hand side of the red image.
    green.crop!(red.columns/3, 0, red.columns/3, red.rows)
    blue.crop!(red.columns/3*2+1, 0, red.columns/3+1, red.rows)
    result = red.composite(green, Magick::CenterGravity, Magick::OverCompositeOp)
    result = result.composite(blue, Magick::EastGravity, Magick::OverCompositeOp)

    # Draw a black line between each of the three images.
    line = Magick::Draw.new
    line.line(result.columns/3, 0, result.columns/3, result.rows)
    line.line(result.columns/3*2+1, 0, result.columns/3*2+1, result.rows)
    line.draw(result)

# Substitute the standard "Not Implemented" image
rescue NotImplementedError
    result = Magick::Image.read("images/notimplemented.gif").first
end

result.write('level_channel.jpg')
exit

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
rmagick-1.10.0 doc/ex/level_channel.rb
rmagick-1.10.1 doc/ex/level_channel.rb
rmagick-1.11.0 doc/ex/level_channel.rb
rmagick-1.11.1 doc/ex/level_channel.rb
rmagick-1.12.0 doc/ex/level_channel.rb
rmagick-1.13.0 doc/ex/level_channel.rb
rmagick-1.7.1 doc/ex/level_channel.rb
rmagick-1.7.2 doc/ex/level_channel.rb
rmagick-1.7.3 doc/ex/level_channel.rb
rmagick-1.7.4 doc/ex/level_channel.rb
rmagick-1.8.0 doc/ex/level_channel.rb
rmagick-1.8.1 doc/ex/level_channel.rb
rmagick-1.8.2 doc/ex/level_channel.rb
rmagick-1.8.3 doc/ex/level_channel.rb
rmagick-1.9.0 doc/ex/level_channel.rb
rmagick-1.9.1 doc/ex/level_channel.rb
rmagick-1.9.2 doc/ex/level_channel.rb
rmagick-1.9.3 doc/ex/level_channel.rb