Class: ShatteredMachine::Transpose

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

Overview

Use the transpose algorithm from pnglitch on a given png image.

Constant Summary collapse

ALL_FILTERS =
%w[none sub up average paeth].freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Transpose

Returns a new instance of Transpose.

Parameters:

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

    options for transpose algorithm



10
11
12
13
# File 'lib/shattered_machine/transpose.rb', line 10

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

Instance Method Details

#call(input_image, output_image) ⇒ boolean

Returns status of transpose.

Parameters:

  • input_image (string)

    path for image

  • output_image (string)

    path for output transposed image

Returns:

  • (boolean)

    status of transpose



18
19
20
21
22
23
# File 'lib/shattered_machine/transpose.rb', line 18

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