rtesseract 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/README.rdoc +21 -1
- data/VERSION +1 -1
- data/lib/processors/quick_magick.rb +29 -0
- data/lib/rtesseract.rb +3 -0
- data/rtesseract.gemspec +4 -3
- data/spec/rtesseract_spec.rb +12 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b00b784a8ad22b0a84816a7c814e587726567972
|
4
|
+
data.tar.gz: a7b1da64782e6d5d5a8bdaf098e6412cd53ca626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccc32c5ce1b558407f3331ada80aa20c1df91409b95b60b4b7c8a534e6e920e643a214744c848acdd2fafcba615edeae22b7612f5c04257e98c7ea8d9a0b31af
|
7
|
+
data.tar.gz: 87430d4c193b95960d28e55002e838d862fd25fe7d3dee1f9be59aa080a3b3dad857957150cc64a8eb6d0a3838ac1dccd0878084f91ff21da3a3a17a6d16012a
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -52,6 +52,7 @@ GEM
|
|
52
52
|
multi_json (~> 1.3)
|
53
53
|
multi_xml (~> 0.5)
|
54
54
|
rack (~> 1.2)
|
55
|
+
quick_magick (0.8.0)
|
55
56
|
rack (1.5.2)
|
56
57
|
rake (10.1.1)
|
57
58
|
rdoc (3.12.2)
|
@@ -86,6 +87,7 @@ DEPENDENCIES
|
|
86
87
|
coveralls
|
87
88
|
jeweler (~> 2.0.1)
|
88
89
|
mini_magick
|
90
|
+
quick_magick
|
89
91
|
rdoc
|
90
92
|
rmagick
|
91
93
|
rspec
|
data/README.rdoc
CHANGED
@@ -11,7 +11,7 @@ Ruby library for working with the Tesseract OCR.
|
|
11
11
|
To work properly rtesseract are needed:
|
12
12
|
* Tesseract - Program
|
13
13
|
* ImageMagic - Program
|
14
|
-
* RMagick or mini_magick - Gem
|
14
|
+
* RMagick or mini_magick or quick_magick - Gem
|
15
15
|
|
16
16
|
Atention: Version 1.0.0 works fine with Ruby 2.0 and tesseract 3.0 and lower versions of rtesseract works fine with Ruby 1.8 and tesseract 2.0.4.
|
17
17
|
|
@@ -58,6 +58,26 @@ It's very simple to use rtesseract:
|
|
58
58
|
]})
|
59
59
|
mix_block.to_s
|
60
60
|
|
61
|
+
=== OPTIONS
|
62
|
+
|
63
|
+
Processors Options (_Rmagick_ is default)
|
64
|
+
|
65
|
+
RTesseract.new("test.jpg", :processor => "mini_magick")
|
66
|
+
|
67
|
+
Language Options
|
68
|
+
|
69
|
+
RTesseract.new("test.jpg", :lang => "deu")
|
70
|
+
* eng - English
|
71
|
+
* deu - German
|
72
|
+
* deu-f - German fraktur
|
73
|
+
* fra - French
|
74
|
+
* ita - Italian
|
75
|
+
* nld - Dutch
|
76
|
+
* por - Portuguese
|
77
|
+
* spa - Spanish
|
78
|
+
* vie - Vietnamese
|
79
|
+
Note: Make sure you have installed the language to tesseract
|
80
|
+
|
61
81
|
== Contributing to rtesseract
|
62
82
|
|
63
83
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# Add to rtesseract a image manipulation with QuickMagick
|
3
|
+
module QuickMagickProcessor
|
4
|
+
def self.setup
|
5
|
+
require 'quick_magick'
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.a_name?(name)
|
9
|
+
%w(quick_magick QuickMagickProcessor).include?(name.to_s)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.image_to_tif(source, x = nil, y = nil, w = nil, h = nil)
|
13
|
+
tmp_file = Tempfile.new(['', '.tif'])
|
14
|
+
cat = source.is_a?(Pathname) ? read_with_processor(source.to_s) : source
|
15
|
+
cat.compress = 'None'
|
16
|
+
cat.format = 'tif'
|
17
|
+
cat.crop("#{w}x#{h}+#{x}+#{y}") unless [x, y, w, h].compact == []
|
18
|
+
cat.write tmp_file.path.to_s
|
19
|
+
tmp_file
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.read_with_processor(path)
|
23
|
+
QuickMagick::Image.read(path.to_s).first
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.image?(object)
|
27
|
+
object.class == QuickMagick::Image
|
28
|
+
end
|
29
|
+
end
|
data/lib/rtesseract.rb
CHANGED
@@ -8,6 +8,7 @@ require 'rtesseract/mixed'
|
|
8
8
|
# Processors
|
9
9
|
require 'processors/rmagick.rb'
|
10
10
|
require 'processors/mini_magick.rb'
|
11
|
+
require 'processors/quick_magick.rb'
|
11
12
|
|
12
13
|
# Ruby wrapper for Tesseract OCR
|
13
14
|
class RTesseract
|
@@ -197,6 +198,8 @@ class RTesseract
|
|
197
198
|
def choose_processor!
|
198
199
|
@processor = if MiniMagickProcessor.a_name?(@processor.to_s)
|
199
200
|
MiniMagickProcessor
|
201
|
+
elsif QuickMagickProcessor.a_name?(@processor.to_s)
|
202
|
+
QuickMagickProcessor
|
200
203
|
else
|
201
204
|
RMagickProcessor
|
202
205
|
end
|
data/rtesseract.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: rtesseract 1.
|
5
|
+
# stub: rtesseract 1.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "rtesseract"
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "1.2.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Danilo Jeremias da Silva"]
|
14
|
-
s.date = "2014-02-
|
14
|
+
s.date = "2014-02-21"
|
15
15
|
s.description = "Ruby library for working with the Tesseract OCR."
|
16
16
|
s.email = "dannnylo@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"Rakefile",
|
31
31
|
"VERSION",
|
32
32
|
"lib/processors/mini_magick.rb",
|
33
|
+
"lib/processors/quick_magick.rb",
|
33
34
|
"lib/processors/rmagick.rb",
|
34
35
|
"lib/rtesseract.rb",
|
35
36
|
"lib/rtesseract/errors.rb",
|
data/spec/rtesseract_spec.rb
CHANGED
@@ -27,6 +27,18 @@ describe "Rtesseract" do
|
|
27
27
|
RTesseract.new(@path.join("images","test.bmp").to_s).to_s_without_spaces.should eql("ZLA6")
|
28
28
|
end
|
29
29
|
|
30
|
+
it " support diferent processors" do
|
31
|
+
#Rmagick
|
32
|
+
RTesseract.new(@image_tiff).to_s_without_spaces.should eql("43ZZ")
|
33
|
+
RTesseract.new(@image_tiff, :processor => 'rmagick').to_s_without_spaces.should eql("43ZZ")
|
34
|
+
|
35
|
+
#MiniMagick
|
36
|
+
RTesseract.new(@image_tiff, :processor => 'mini_magick').to_s_without_spaces.should eql("43ZZ")
|
37
|
+
|
38
|
+
#QuickMagick
|
39
|
+
RTesseract.new(@image_tiff, :processor => 'quick_magick').to_s_without_spaces.should eql("43ZZ")
|
40
|
+
end
|
41
|
+
|
30
42
|
it " change the image" do
|
31
43
|
image = RTesseract.new(@image_tiff)
|
32
44
|
image.to_s_without_spaces.should eql("43ZZ")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtesseract
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danilo Jeremias da Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- Rakefile
|
114
114
|
- VERSION
|
115
115
|
- lib/processors/mini_magick.rb
|
116
|
+
- lib/processors/quick_magick.rb
|
116
117
|
- lib/processors/rmagick.rb
|
117
118
|
- lib/rtesseract.rb
|
118
119
|
- lib/rtesseract/errors.rb
|