Sha256: 9c438585381eb01a85fd6704112ca62423312095ba4c16d2116562ff64bf9cb8

Contents?: true

Size: 558 Bytes

Versions: 1

Compression:

Stored size: 558 Bytes

Contents

require 'rmagick'

module Yearbook
  module Manipulator

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


      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

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

        img.resize_to_fit(w, h)
      end


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


    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yearbook-0.3.0 lib/yearbook/manipulator.rb