Module: Yearbook::Manipulator

Defined in:
lib/yearbook/manipulator.rb

Class Method Summary collapse

Class Method Details

.bw(img, num_colors = 128) ⇒ Object



7
8
9
# File 'lib/yearbook/manipulator.rb', line 7

def bw(img, num_colors = 128)
  img.quantize(num_colors, Magick::GRAYColorspace)
end

.constitute(img, *args) ⇒ Object



12
13
14
15
16
17
# File 'lib/yearbook/manipulator.rb', line 12

def constitute(img, *args)
  x,y,w,h = args[0..3]
  pixels = img.dispatch(x, y, w, h, "RGB")

  Magick::Image.constitute(w, h, "RGB", pixels)
end

.load_magick(fname) ⇒ Object



26
27
28
# File 'lib/yearbook/manipulator.rb', line 26

def load_magick(fname)
  Magick::Image::read(fname).first
end

.resize_to_fit(img, w, h = nil) ⇒ Object



19
20
21
22
23
# File 'lib/yearbook/manipulator.rb', line 19

def resize_to_fit(img, w, h = nil)
  h ||= w

  img.resize_to_fit(w, h)
end