Class: Privatize::Pixelate

Inherits:
Image
  • Object
show all
Defined in:
lib/privatize/pixelate.rb

Instance Attribute Summary

Attributes inherited from Image

#output, #path

Instance Method Summary collapse

Methods inherited from Image

#dirname, effects, #ext, #filename, #image, #info, #output_path

Constructor Details

#initialize(path, options = {}) ⇒ Pixelate

Returns a new instance of Pixelate.



5
6
7
# File 'lib/privatize/pixelate.rb', line 5

def initialize path, options={}
  super
end

Instance Method Details

#normalize(n) ⇒ Object



9
10
11
# File 'lib/privatize/pixelate.rb', line 9

def normalize n
  @percentage = n < 51 ? ((n*2)/100.0)*10 : 10 + 25 * ((n-50)/49.0)
end

#process!(level = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/privatize/pixelate.rb', line 13

def process! level=nil
  tiny = level || 50 
  MiniMagick::Tool::Convert.new do |convert|
    convert.scale("#{normalize(100 - tiny.to_i)}%")
    convert.scale("#{info['width']}x#{info['height']}!")
    convert << @path
    convert << output_path(tiny)
  end
end