thumbkit 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +12 -2
- data/lib/thumbkit/adapters/carrierwave.rb +1 -1
- data/lib/thumbkit/processor/image.rb +9 -3
- data/lib/thumbkit/processor.rb +2 -0
- data/lib/thumbkit/version.rb +1 -1
- data/spec/fixtures/OMG_UPPERCASE.PNG +0 -0
- data/spec/fixtures/OMG_UPPERCASE_TEXT.TXT +15 -0
- data/spec/thumbkit/processor/image_spec.rb +28 -0
- data/spec/thumbkit/processor/text_spec.rb +9 -0
- metadata +5 -1
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -47,8 +47,12 @@ thumbnail type.
|
|
47
47
|
Thumbkit uses [MiniMagick](https://github.com/probablycorey/mini_magick) to
|
48
48
|
resize and crop images.
|
49
49
|
|
50
|
+
If you plan to support thumbnails raw files, imagemagick delegate raw processing
|
51
|
+
to [ufraw](http://ufraw.sourceforge.net/).
|
52
|
+
|
50
53
|
On OS X:
|
51
54
|
|
55
|
+
$ brew install ufraw # Optional, for processing cr2, raw, etc
|
52
56
|
$ brew install imagemagick
|
53
57
|
$ gem install mini_magick
|
54
58
|
|
@@ -232,10 +236,10 @@ Adding a processor mapping:
|
|
232
236
|
Thumbkit.processors['jpeg'] = 'Image'
|
233
237
|
```
|
234
238
|
|
235
|
-
|
239
|
+
##### Custom processors
|
236
240
|
|
237
241
|
```ruby
|
238
|
-
class Thumbkit::
|
242
|
+
class Thumbkit::Processor::Doc < Thumbkit::Processor
|
239
243
|
def write
|
240
244
|
# use `path` to generate `outfile`
|
241
245
|
|
@@ -258,6 +262,12 @@ Thumbkit.processors['doc'] = 'Doc'
|
|
258
262
|
* PDF
|
259
263
|
* Video
|
260
264
|
|
265
|
+
## Known Issues
|
266
|
+
|
267
|
+
* If the output file has an uppercase extension, image processing may break.
|
268
|
+
This will not be an issue if you are not supplying the output filename as
|
269
|
+
`Thumbkit::Image` will always pick a lowercase extension by default.
|
270
|
+
|
261
271
|
## Contributing
|
262
272
|
|
263
273
|
1. Fork it
|
@@ -3,7 +3,8 @@ require 'mini_magick'
|
|
3
3
|
class Thumbkit::Processor::Image < Thumbkit::Processor
|
4
4
|
|
5
5
|
def determine_outfile
|
6
|
-
@path
|
6
|
+
ext = File.extname(@path)[1..-1].downcase
|
7
|
+
self.class.force_extension(path, format_conversions[ext] || ext)
|
7
8
|
end
|
8
9
|
|
9
10
|
def write
|
@@ -12,7 +13,13 @@ class Thumbkit::Processor::Image < Thumbkit::Processor
|
|
12
13
|
outfile
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
+
# Public to allow customization
|
17
|
+
def format_conversions
|
18
|
+
@_format_conversions ||= {
|
19
|
+
'cr2' => 'jpg',
|
20
|
+
'raw' => 'jpg',
|
21
|
+
}
|
22
|
+
end
|
16
23
|
|
17
24
|
private
|
18
25
|
|
@@ -20,7 +27,6 @@ class Thumbkit::Processor::Image < Thumbkit::Processor
|
|
20
27
|
File.extname(outfile)[1..-1]
|
21
28
|
end
|
22
29
|
|
23
|
-
|
24
30
|
# Copied and adjusted from CarrierWave
|
25
31
|
def resize_to_fill
|
26
32
|
image = ::MiniMagick::Image.open(path)
|
data/lib/thumbkit/processor.rb
CHANGED
data/lib/thumbkit/version.rb
CHANGED
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
An Example Text File
|
2
|
+
|
3
|
+
LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISICING ELIT, SED DO EIUSMOD
|
4
|
+
TEMPOR INCIDIDUNT UT LABORE ET DOLORE MAGNA ALIQUA. UT ENIM AD MINIM VENIAM,
|
5
|
+
QUIS NOSTRUD EXERCITATION ULLAMCO LABORIS NISI UT ALIQUIP EX EA COMMODO
|
6
|
+
CONSEQUAT. DUIS AUTE IRURE DOLOR IN REPREHENDERIT IN VOLUPTATE VELIT ESSE
|
7
|
+
CILLUM DOLORE EU FUGIAT NULLA PARIATUR. EXCEPTEUR SINT OCCAECAT CUPIDATAT NON
|
8
|
+
PROIDENT, SUNT IN CULPA QUI OFFICIA DESERUNT MOLLIT ANIM ID EST LABORUM.
|
9
|
+
|
10
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
11
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
12
|
+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
13
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
14
|
+
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
|
15
|
+
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
@@ -20,6 +20,16 @@ describe Thumbkit::Processor::Image do
|
|
20
20
|
let(:fixture) { 'jpg_file.jpg' }
|
21
21
|
it { should == File.expand_path(path_to_fixture('jpg_file.jpg')) }
|
22
22
|
end
|
23
|
+
|
24
|
+
context 'when the fixture is a cr2' do
|
25
|
+
let(:fixture) { 'IMAGE_RAW_EXAMPLE.CR2' }
|
26
|
+
it { should == File.expand_path(path_to_fixture('IMAGE_RAW_EXAMPLE.jpg')) }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'with an uppercase file' do
|
30
|
+
let(:fixture) { 'OMG_UPPERCASE.PNG' }
|
31
|
+
it { should == File.expand_path(path_to_fixture('OMG_UPPERCASE.png')) }
|
32
|
+
end
|
23
33
|
end
|
24
34
|
|
25
35
|
# context 'with an extensionless outfile' do
|
@@ -77,5 +87,23 @@ describe Thumbkit::Processor::Image do
|
|
77
87
|
its_size_should_be('200x200')
|
78
88
|
its_mimetype_should_be('image/jpeg')
|
79
89
|
end
|
90
|
+
|
91
|
+
context 'with an uppercase file' do
|
92
|
+
let(:fixture) { path_to_fixture('OMG_UPPERCASE.PNG') }
|
93
|
+
let(:outfile) { path_for_output('OMG_UPPERCASE.png').to_s }
|
94
|
+
it { should == path_for_output('OMG_UPPERCASE.png').to_s }
|
95
|
+
its_size_should_be('200x200')
|
96
|
+
its_mimetype_should_be('image/png')
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
# Extremely SLOW
|
101
|
+
# context 'with a raw file' do
|
102
|
+
# let(:fixture) { 'IMG_RAW_EXAMPLE.CR2' }
|
103
|
+
# let(:outfile) { path_for_output('IMAGE_RAW_EXAMPLE.jpg').to_s }
|
104
|
+
# it { should == path_for_output('IMAGE_RAW_EXAMPLE.jpg').to_s }
|
105
|
+
# its_size_should_be('200x200')
|
106
|
+
# its_mimetype_should_be('image/jpeg')
|
107
|
+
# end
|
80
108
|
end
|
81
109
|
end
|
@@ -104,6 +104,15 @@ describe Thumbkit::Processor::Text do
|
|
104
104
|
# Manually check the file to verify unicode stuff and right-to-left worked
|
105
105
|
end
|
106
106
|
|
107
|
+
context 'with an uppercase filename' do
|
108
|
+
let(:options) { { } }
|
109
|
+
let(:fixture) { 'OMG_UPPERCASE_TEXT.TXT' }
|
110
|
+
let(:outfile) { path_for_output('OMG_UPPERCASE_TEXT.PNG').to_s }
|
111
|
+
it('writes a file') { File.should exist(subject) }
|
112
|
+
its_size_should_be('200x200')
|
113
|
+
its_mimetype_should_be('image/png')
|
114
|
+
end
|
115
|
+
|
107
116
|
|
108
117
|
context 'with an arabic file to output to jpg' do
|
109
118
|
let(:options) { { width: 600, height: 400 } }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thumbkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -35,6 +35,8 @@ files:
|
|
35
35
|
- lib/thumbkit/processor/text.rb
|
36
36
|
- lib/thumbkit/version.rb
|
37
37
|
- spec/fixtures/16Hz-20kHz-Exp-1f-5sec.mp3
|
38
|
+
- spec/fixtures/OMG_UPPERCASE.PNG
|
39
|
+
- spec/fixtures/OMG_UPPERCASE_TEXT.TXT
|
38
40
|
- spec/fixtures/arabic.txt
|
39
41
|
- spec/fixtures/greek.txt
|
40
42
|
- spec/fixtures/hebrew.txt
|
@@ -76,6 +78,8 @@ specification_version: 3
|
|
76
78
|
summary: Thumbkit makes thumbnails from a variety of media types.
|
77
79
|
test_files:
|
78
80
|
- spec/fixtures/16Hz-20kHz-Exp-1f-5sec.mp3
|
81
|
+
- spec/fixtures/OMG_UPPERCASE.PNG
|
82
|
+
- spec/fixtures/OMG_UPPERCASE_TEXT.TXT
|
79
83
|
- spec/fixtures/arabic.txt
|
80
84
|
- spec/fixtures/greek.txt
|
81
85
|
- spec/fixtures/hebrew.txt
|