Class: ShatteredMachine::WrongFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/shattered_machine/wrong_filter.rb

Overview

Use the wrong filter algorithm from pnglitch on a given png image.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ WrongFilter

Returns a new instance of WrongFilter.

Parameters:

  • options (Hash) (defaults to: {})

    options for wrong filter algorithm



8
9
10
# File 'lib/shattered_machine/wrong_filter.rb', line 8

def initialize(options = {})
  @filter = options[:filter] || 'average'
end

Instance Method Details

#call(input_image, output_image) ⇒ boolean

Returns status of wrong filter.

Parameters:

  • input_image (string)

    path for image

  • output_image (string)

    path for output wrong filtered image

Returns:

  • (boolean)

    status of wrong filter



15
16
17
18
19
20
# File 'lib/shattered_machine/wrong_filter.rb', line 15

def call(input_image, output_image)
  PNGlitch.open(input_image) do |png|
    filtered_glitch(png, @filter).save output_image
  end
  output_image
end