grim 0.3.0 → 1.0.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.
- data/Gemfile +3 -3
- data/README.textile +16 -3
- data/lib/grim.rb +3 -0
- data/lib/grim/image_magick_processor.rb +3 -2
- data/lib/grim/version.rb +1 -1
- data/spec/lib/grim/image_magick_processor_spec.rb +18 -0
- data/spec/lib/grim/page_spec.rb +2 -2
- data/spec/lib/grim_spec.rb +4 -0
- metadata +24 -40
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
gemspec
|
3
|
-
gem
|
4
|
-
gem
|
3
|
+
gem "rake"
|
4
|
+
gem "rspec"
|
data/README.textile
CHANGED
@@ -23,10 +23,10 @@ Grim is a simple gem for extracting (reaping) a page from a pdf and converting i
|
|
23
23
|
|
24
24
|
h2. Prerequisites
|
25
25
|
|
26
|
-
You will need ghostscript, imagemagick, and
|
26
|
+
You will need ghostscript, imagemagick, and poppler installed. On the Mac (OSX) I highly recommend using "Homebrew":http://mxcl.github.com/homebrew/ to get them installed.
|
27
27
|
|
28
28
|
<pre><code>
|
29
|
-
brew install ghostscript imagemagick
|
29
|
+
brew install ghostscript imagemagick poppler
|
30
30
|
</code></pre>
|
31
31
|
|
32
32
|
h2. Installation
|
@@ -63,6 +63,19 @@ We also support using other processors (the default is whatever version of Image
|
|
63
63
|
pdf = Grim.reap('/path/to/pdf)
|
64
64
|
</code></pre>
|
65
65
|
|
66
|
+
h2. Reference
|
67
|
+
|
68
|
+
* "jonmagic.com: Grim":http://jonmagic.com/blog/archives/2011/09/06/grim/
|
69
|
+
* "jonmagic.com: Grim MultiProcessor":http://jonmagic.com/blog/archives/2011/10/06/grim-multiprocessor-to-the-rescue/
|
70
|
+
|
71
|
+
h2. Contributors
|
72
|
+
|
73
|
+
* "@jonmagic":https://github.com/jonmagic
|
74
|
+
* "@jnunemaker":https://github.com/jnunemaker
|
75
|
+
* "@bryckbost":https://github.com/bryckbost
|
76
|
+
* "@bkeepers":https://github.com/bkeepers
|
77
|
+
* "@BobaFaux":https://github.com/BobaFaux
|
78
|
+
|
66
79
|
h2. License
|
67
80
|
|
68
|
-
See LICENSE for details.
|
81
|
+
See LICENSE for details.
|
data/lib/grim.rb
CHANGED
@@ -23,8 +23,9 @@ module Grim
|
|
23
23
|
width = options.fetch(:width, Grim::WIDTH)
|
24
24
|
density = options.fetch(:density, Grim::DENSITY)
|
25
25
|
quality = options.fetch(:quality, Grim::QUALITY)
|
26
|
+
colorspace = options.fetch(:colorspace, Grim::COLORSPACE)
|
26
27
|
command = [@imagemagick_path, "-resize", width.to_s, "-antialias", "-render",
|
27
|
-
"-quality", quality.to_s, "-colorspace",
|
28
|
+
"-quality", quality.to_s, "-colorspace", colorspace,
|
28
29
|
"-interlace", "none", "-density", density.to_s,
|
29
30
|
"#{Shellwords.shellescape(pdf.path)}[#{index}]", path]
|
30
31
|
command.unshift("PATH=#{File.dirname(@ghostscript_path)}:#{ENV['PATH']}") if @ghostscript_path
|
@@ -34,4 +35,4 @@ module Grim
|
|
34
35
|
$? == 0 || raise(UnprocessablePage, result)
|
35
36
|
end
|
36
37
|
end
|
37
|
-
end
|
38
|
+
end
|
data/lib/grim/version.rb
CHANGED
@@ -84,4 +84,22 @@ describe Grim::ImageMagickProcessor do
|
|
84
84
|
(lower_time < higher_time).should be_true
|
85
85
|
end
|
86
86
|
end
|
87
|
+
|
88
|
+
describe "#save with colorspace option" do
|
89
|
+
before(:each) do
|
90
|
+
@path1 = tmp_path("to_png_spec-1.jpg")
|
91
|
+
@path2 = tmp_path("to_png_spec-2.jpg")
|
92
|
+
@pdf = Grim::Pdf.new(fixture_path("smoker.pdf"))
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should use colorspace" do
|
96
|
+
Grim::ImageMagickProcessor.new.save(@pdf, 0, @path1, {:colorspace => 'RGB'})
|
97
|
+
Grim::ImageMagickProcessor.new.save(@pdf, 0, @path2, {:colorspace => 'sRGB'})
|
98
|
+
|
99
|
+
file1_size = File.stat(@path1).size
|
100
|
+
file2_size = File.stat(@path2).size
|
101
|
+
|
102
|
+
file1_size.should_not == file2_size
|
103
|
+
end
|
104
|
+
end
|
87
105
|
end
|
data/spec/lib/grim/page_spec.rb
CHANGED
@@ -47,7 +47,7 @@ describe Grim::Page do
|
|
47
47
|
describe "#text" do
|
48
48
|
it "should return the text from the selected page" do
|
49
49
|
pdf = Grim::Pdf.new(fixture_path("smoker.pdf"))
|
50
|
-
pdf[1].text.should == "Step 1: get someone to print this curve for you to scale, 72
|
50
|
+
pdf[1].text.should == "Step 1: get someone to print this curve for you to scale, 72” wide\n\nStep 2: Get a couple 55 gallon drums\n\n\f"
|
51
51
|
end
|
52
52
|
end
|
53
|
-
end
|
53
|
+
end
|
data/spec/lib/grim_spec.rb
CHANGED
@@ -22,6 +22,10 @@ describe Grim do
|
|
22
22
|
Grim::DENSITY.should == 300
|
23
23
|
end
|
24
24
|
|
25
|
+
it "should have COLORSPACE constant set to 'RGB'" do
|
26
|
+
Grim::COLORSPACE.should == 'RGB'
|
27
|
+
end
|
28
|
+
|
25
29
|
describe "#reap" do
|
26
30
|
it "should return an instance of Grim::Pdf" do
|
27
31
|
Grim.reap(fixture_path("smoker.pdf")).class.should == Grim::Pdf
|
metadata
CHANGED
@@ -1,33 +1,26 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: grim
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 0
|
10
|
-
version: 0.3.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jonathan Hoyt
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-10-04 00:00:00 Z
|
12
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
description: Grim is a simple gem for extracting a page from a pdf and converting
|
15
|
+
it to an image as well as extract the text from the page as a string. It basically
|
16
|
+
gives you an easy to use api to ghostscript, imagemagick, and pdftotext specific
|
17
|
+
to this use case.
|
18
|
+
email:
|
23
19
|
- jonmagic@gmail.com
|
24
20
|
executables: []
|
25
|
-
|
26
21
|
extensions: []
|
27
|
-
|
28
22
|
extra_rdoc_files: []
|
29
|
-
|
30
|
-
files:
|
23
|
+
files:
|
31
24
|
- .gitignore
|
32
25
|
- Gemfile
|
33
26
|
- LICENSE
|
@@ -51,38 +44,29 @@ files:
|
|
51
44
|
- spec/spec_helper.rb
|
52
45
|
homepage: http://github.com/jonmagic/grim
|
53
46
|
licenses: []
|
54
|
-
|
55
47
|
post_install_message:
|
56
48
|
rdoc_options: []
|
57
|
-
|
58
|
-
require_paths:
|
49
|
+
require_paths:
|
59
50
|
- lib
|
60
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
52
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
66
|
-
|
67
|
-
- 0
|
68
|
-
version: "0"
|
69
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
58
|
none: false
|
71
|
-
requirements:
|
72
|
-
- -
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
version: "0"
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
78
63
|
requirements: []
|
79
|
-
|
80
64
|
rubyforge_project: grim
|
81
|
-
rubygems_version: 1.8.
|
65
|
+
rubygems_version: 1.8.23
|
82
66
|
signing_key:
|
83
67
|
specification_version: 3
|
84
68
|
summary: Extract slides and text from a PDF.
|
85
|
-
test_files:
|
69
|
+
test_files:
|
86
70
|
- spec/fixtures/smoker.pdf
|
87
71
|
- spec/fixtures/unprocessable.pdf
|
88
72
|
- spec/lib/grim/image_magick_processor_spec.rb
|