Module: RTesseract::Processor::MiniMagickProcessor
- Defined in:
- lib/processors/mini_magick.rb
Overview
Add to rtesseract a image manipulation with MiniMagick
Class Method Summary collapse
-
.a_name?(name) ⇒ Boolean
Check if is this Processor.
-
.image?(object) ⇒ Boolean
Check if is a MiniMagick image.
-
.image_to_tif(source, points = {}) ⇒ Object
Convert Image to Tiff.
-
.read_with_processor(path) ⇒ Object
Cast instance of image.
-
.setup ⇒ Object
Setup Processor.
Class Method Details
.a_name?(name) ⇒ Boolean
Check if is this Processor
14 15 16 |
# File 'lib/processors/mini_magick.rb', line 14 def self.a_name?(name) %w(mini_magick MiniMagickProcessor).include?(name.to_s) end |
.image?(object) ⇒ Boolean
Check if is a MiniMagick image
38 39 40 |
# File 'lib/processors/mini_magick.rb', line 38 def self.image?(object) object.class == MiniMagick::Image end |
.image_to_tif(source, points = {}) ⇒ Object
Convert Image to Tiff
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/processors/mini_magick.rb', line 19 def self.image_to_tif(source, points = {}) tmp_file = Tempfile.new(['', '.tif']) cat = source.is_a?(Pathname) ? read_with_processor(source.to_s) : source cat.format('tif') do |c| c.compress 'None' c.alpha 'off' if MiniMagick.cli != :graphicsmagick end cat.crop("#{points[:w]}x#{points[:h]}+#{points[:x]}+#{points[:y]}") if points.is_a?(Hash) && points.values.compact != [] cat.alpha 'off' if MiniMagick.cli != :graphicsmagick cat.write tmp_file.path.to_s tmp_file end |
.read_with_processor(path) ⇒ Object
Cast instance of image
33 34 35 |
# File 'lib/processors/mini_magick.rb', line 33 def self.read_with_processor(path) MiniMagick::Image.open(path.to_s) end |
.setup ⇒ Object
Setup Processor
9 10 11 |
# File 'lib/processors/mini_magick.rb', line 9 def self.setup require 'mini_magick' end |