carrierwave-vips 0.9.1 → 0.9.9
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/lib/carrierwave/vips.rb +10 -15
- metadata +2 -2
data/lib/carrierwave/vips.rb
CHANGED
@@ -181,40 +181,36 @@ module CarrierWave
|
|
181
181
|
private
|
182
182
|
|
183
183
|
def resize_image(image, width, height, min_or_max = :min)
|
184
|
-
|
185
184
|
ratio = get_ratio image, width, height, min_or_max
|
186
|
-
|
187
185
|
if jpeg? # find the shrink ratio for loading
|
188
|
-
|
189
|
-
shrink_factor = nil
|
190
|
-
|
191
|
-
|
192
|
-
image = VIPS::Image.jpeg current_path, shrink_factor: shrink_factor, sequential: true
|
186
|
+
shrink_factor = [8, 4, 2, 1].find {|sf| 1.0 / ratio >= sf }
|
187
|
+
shrink_factor = 1 if shrink_factor == nil
|
188
|
+
image = VIPS::Image.jpeg current_path,
|
189
|
+
:shrink_factor => shrink_factor, :sequential => true
|
193
190
|
ratio = get_ratio image, width, height, min_or_max
|
194
191
|
elsif png?
|
195
192
|
image = VIPS::Image.png current_path, :sequential => true
|
196
193
|
end
|
197
|
-
|
198
194
|
if ratio > 1
|
199
195
|
image = image.affinei_resize :nearest, ratio
|
200
|
-
|
196
|
+
else
|
201
197
|
if ratio <= 0.5
|
202
|
-
|
198
|
+
factor = (1.0 / ratio).floor
|
199
|
+
image = image.shrink(factor)
|
200
|
+
image = image.tile_cache(image.x_size, 1, 30)
|
203
201
|
ratio = get_ratio image, width, height, min_or_max
|
204
202
|
end
|
205
203
|
image = image.affinei_resize :bilinear, ratio unless ratio == 1
|
206
|
-
image = image.tile_cache(image.x_size, 1, 30)
|
207
204
|
image = image.conv SHARPEN_MASK
|
208
205
|
end
|
209
|
-
|
210
206
|
image
|
211
|
-
|
212
207
|
end
|
213
208
|
|
214
209
|
def get_ratio(image, width,height, min_or_max = :min)
|
215
210
|
width_ratio = width.to_f / image.x_size
|
216
211
|
height_ratio = height.to_f / image.y_size
|
217
|
-
[width_ratio, height_ratio].send(min_or_max)
|
212
|
+
ratio = [width_ratio, height_ratio].send(min_or_max)
|
213
|
+
ratio
|
218
214
|
end
|
219
215
|
|
220
216
|
def jpeg?(path = current_path)
|
@@ -224,7 +220,6 @@ module CarrierWave
|
|
224
220
|
def png?(path = current_path)
|
225
221
|
path =~ /.*png$/i
|
226
222
|
end
|
227
|
-
|
228
223
|
|
229
224
|
end # Vips
|
230
225
|
end # CarrierWave
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-vips
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Adds VIPS support to CarrierWave
|
15
15
|
email: eltiare@github.com
|