File: quantize_m.rb

package info (click to toggle)
ruby-rmagick 6.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,232 kB
  • sloc: cpp: 19,563; ruby: 17,147; sh: 88; javascript: 36; makefile: 13
file content (23 lines) | stat: -rw-r--r-- 668 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Demonstrate the ImageList#quantize method

require 'rmagick'

snapshots = Magick::ImageList.new 'images/Ballerina.jpg', 'images/Gold_Statue.jpg', 'images/Shorts.jpg'

# Quantize all 3 images to a single set of 16 colors in the RGB colorspace
$stdout.sync = true
printf 'Quantizing... Please be patient, this may take a couple of seconds... '
quant = snapshots.quantize 16
puts 'Done.'

# Now we create the "before" and "after" images.
# Arrange the original images side-by-side into a
# single image.
old = snapshots.append false
old.write('quantize_m_before.jpg')

# Repeat for the quantized images.
new = quant.append false
new.write('quantize_m_after.jpg')

exit