Sha256: 66d149c048e48e5f521da8b739cb524c4b9acab730757b874fb4f39148a14b25

Contents?: true

Size: 819 Bytes

Versions: 30

Compression:

Stored size: 819 Bytes

Contents

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

# Demonstrate the Image#contrast method

img = Magick::ImageList.new('images/Flower_Hat.jpg')
img.resize!(0.5)

# Prepare to label each image with a number from 1 to 4
legend = Magick::Draw.new
legend.font_family = 'Helvetica'
legend.stroke = 'transparent'
legend.pointsize = 12
legend.gravity = Magick::SouthEastGravity

# Add 3 images, each one having slightly less contrast
f = 1
3.times {
    img << img.contrast

    # Annotate the previous image
    legend.annotate(img[f-1], 0,0,7,10, f.to_s)
    f += 1
    }

# Annotate the last image
legend.annotate(img, 0,0,7,10, f.to_s)

# Montage into a single image
imgs = img.montage {
    self.geometry = Magick::Geometry.new(img.columns, img.rows)
    self.tile = "2x2"
    }

imgs.write('contrast.jpg')
#imgs.display
exit

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
rmagick-1.10.1 doc/ex/contrast.rb
rmagick-1.10.0 doc/ex/contrast.rb
rmagick-1.11.0 doc/ex/contrast.rb
rmagick-1.11.1 doc/ex/contrast.rb
rmagick-1.12.0 doc/ex/contrast.rb
rmagick-1.13.0 doc/ex/contrast.rb
rmagick-1.15.1 doc/ex/contrast.rb
rmagick-1.15.0 doc/ex/contrast.rb
rmagick-1.14.0 doc/ex/contrast.rb
rmagick-1.14.1 doc/ex/contrast.rb
rmagick-1.15.2 doc/ex/contrast.rb
rmagick-1.15.4 doc/ex/contrast.rb
rmagick-1.15.3 doc/ex/contrast.rb
rmagick-1.15.5 doc/ex/contrast.rb
rmagick-1.15.7 doc/ex/contrast.rb
rmagick-1.15.8 doc/ex/contrast.rb
rmagick-1.15.6 doc/ex/contrast.rb
rmagick-1.7.3 doc/ex/contrast.rb
rmagick-1.7.1 doc/ex/contrast.rb
rmagick-1.15.9 doc/ex/contrast.rb