Sha256: b61efc8643e8c1cd86622605763a4b3eace7d72f8f6652294668cef94569606d
Contents?: true
Size: 850 Bytes
Versions: 1
Compression:
Stored size: 850 Bytes
Contents
# encoding: UTF-8 # Add to rtesseract a image manipulation with MiniMagick module MiniMagickProcessor def self.setup require 'mini_magick' end def self.a_name?(name) %w(mini_magick MiniMagickProcessor).include?(name.to_s) end 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' end cat.crop("#{_points[:w]}x#{_points[:h]}+#{_points[:x]}+#{_points[:y]}") if _points.is_a?(Hash) && _points.values.compact != [] cat.alpha 'off' cat.write tmp_file.path.to_s tmp_file end def self.read_with_processor(path) MiniMagick::Image.open(path.to_s) end def self.image?(object) object.class == MiniMagick::Image end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rtesseract-2.0.0 | lib/processors/mini_magick.rb |