Class: Despeck::WatermarkRemover

Inherits:
Object
  • Object
show all
Defined in:
lib/despeck/watermark_remover.rb

Overview

Takes an image and removes watermark

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ WatermarkRemover

Returns a new instance of WatermarkRemover.



9
10
11
12
13
14
15
# File 'lib/despeck/watermark_remover.rb', line 9

def initialize(options = {})
  apply_options!(options)

  Despeck.logger.debug "Sensitivity: #{sensitivity}"
  Despeck.logger.debug "Contrast improvement: #{add_contrast}"
  Despeck.logger.debug "Black level improvement: #{black_const}"
end

Instance Attribute Details

#accurateObject (readonly)

Returns the value of attribute accurate.



6
7
8
# File 'lib/despeck/watermark_remover.rb', line 6

def accurate
  @accurate
end

#add_contrastObject (readonly)

Returns the value of attribute add_contrast.



6
7
8
# File 'lib/despeck/watermark_remover.rb', line 6

def add_contrast
  @add_contrast
end

#black_constObject (readonly)

Returns the value of attribute black_const.



6
7
8
# File 'lib/despeck/watermark_remover.rb', line 6

def black_const
  @black_const
end

#resizeObject (readonly)

Returns the value of attribute resize.



6
7
8
# File 'lib/despeck/watermark_remover.rb', line 6

def resize
  @resize
end

#sensitivityObject (readonly)

Returns the value of attribute sensitivity.



6
7
8
# File 'lib/despeck/watermark_remover.rb', line 6

def sensitivity
  @sensitivity
end

#watermark_colorObject (readonly)

Returns the value of attribute watermark_color.



6
7
8
# File 'lib/despeck/watermark_remover.rb', line 6

def watermark_color
  @watermark_color
end

Instance Method Details

#remove_watermark(image) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/despeck/watermark_remover.rb', line 17

def remove_watermark(image)
  output_image = nil
  time =
    Benchmark.realtime do
      output_image =
        if accurate
          __remove_watermark_only__(image)
        else
          __remove_watermark__(image)
        end
    end
  Despeck.logger.debug "Time taken: #{time} seconds"

  output_image
end