thumbkit 0.0.7 → 0.0.8

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.lock CHANGED
@@ -10,7 +10,7 @@ GIT
10
10
  PATH
11
11
  remote: .
12
12
  specs:
13
- thumbkit (0.0.6)
13
+ thumbkit (0.0.7)
14
14
 
15
15
  GEM
16
16
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -113,6 +113,12 @@ you'll have to install them yourself.
113
113
 
114
114
  Will write a 200x200 cropped image to `path/to/image.jpg`.
115
115
 
116
+ To get an image resized to fit instead of cropped:
117
+
118
+ ```ruby
119
+ Thumbkit.new('path/to/image.jpg', crop: false).write_thumbnail
120
+ ```
121
+
116
122
  The format of the output file will depend on the extension of the output path
117
123
  and defaults to the same as the input file.
118
124
 
@@ -203,6 +209,7 @@ All settings can be set globally. These are the defaults:
203
209
  Thumbkit.defaults = {
204
210
  width: 200, height: 200,
205
211
  gravity: 'Center',
212
+ crop: true,
206
213
  colors: { foreground: '#888888', background: '#eeeeee' },
207
214
  font: {
208
215
  family: 'Arial-Regular',
@@ -8,7 +8,7 @@ class Thumbkit::Processor::Image < Thumbkit::Processor
8
8
  end
9
9
 
10
10
  def write
11
- resize_to_fill
11
+ options[:crop] ? resize_to_fill : resize_to_fit
12
12
 
13
13
  outfile
14
14
  end
@@ -37,6 +37,13 @@ class Thumbkit::Processor::Image < Thumbkit::Processor
37
37
  end
38
38
 
39
39
  # Copied and adjusted from CarrierWave
40
+
41
+ def resize_to_fit
42
+ image = ::MiniMagick::Image.open(path)
43
+ image.resize "#{options[:width]}x#{options[:height]}"
44
+ image.write(outfile)
45
+ end
46
+
40
47
  def resize_to_fill
41
48
  image = ::MiniMagick::Image.open(path)
42
49
 
@@ -1,3 +1,3 @@
1
1
  class Thumbkit
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/lib/thumbkit.rb CHANGED
@@ -9,6 +9,9 @@ class Thumbkit
9
9
  @defaults ||= Thumbkit::Options.new({
10
10
  width: 200,
11
11
  height: 200,
12
+ # Whether or not we crop to fill the entire thumbnail size.
13
+ # Only affects images.
14
+ crop: true,
12
15
  # Run `identify -list Gravity` for a list of available options
13
16
  gravity: 'Center',
14
17
  colors: {
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.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: