Sha256: 0c9b25796d9273bd959b2430efc1f08dbf847db7ec63008e4e823422bb8561b9

Contents?: true

Size: 769 Bytes

Versions: 13

Compression:

Stored size: 769 Bytes

Contents

#!/usr/bin/env 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.stroke = 'transparent'
legend.pointsize = 12
legend.gravity = Magick::SouthEastGravity

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

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

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

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

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

Version data entries

13 entries across 13 versions & 3 rubygems

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