Class: TRMNLP::ImageQuantizer
- Inherits:
-
Object
- Object
- TRMNLP::ImageQuantizer
- Defined in:
- lib/trmnlp/image_quantizer.rb
Constant Summary collapse
- MIN_DEPTH =
1- MAX_DEPTH =
8
Instance Method Summary collapse
- #call(path) ⇒ Object
-
#initialize(depth:) ⇒ ImageQuantizer
constructor
A new instance of ImageQuantizer.
Constructor Details
#initialize(depth:) ⇒ ImageQuantizer
Returns a new instance of ImageQuantizer.
12 13 14 |
# File 'lib/trmnlp/image_quantizer.rb', line 12 def initialize(depth:) @depth = clamp(depth) end |
Instance Method Details
#call(path) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/trmnlp/image_quantizer.rb', line 16 def call(path) tmp = Tempfile.new(['mono', '.png']) tmp.close quantize(path, tmp.path) FileUtils.mv(tmp.path, path, force: true) end |